mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
* detect unused typescript disables * fix lint errors uuid-types remove debug fix config * lint fixes
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
/* eslint-disable @typescript-eslint/require-await */
|
|
|
|
import { categories } from '@constants/categories'
|
|
|
|
import { getDriver } from './neo4j'
|
|
|
|
const createCategories = async () => {
|
|
const driver = getDriver()
|
|
const session = driver.session()
|
|
const createCategoriesTxResultPromise = session.writeTransaction(async (txc) => {
|
|
categories.forEach(({ icon, name }, index) => {
|
|
const id = `cat${index + 1}`
|
|
txc.run(
|
|
`MERGE (c:Category {
|
|
icon: "${icon}",
|
|
slug: "${name}",
|
|
name: "${name}",
|
|
id: "${id}",
|
|
createdAt: toString(datetime())
|
|
})`,
|
|
)
|
|
})
|
|
})
|
|
try {
|
|
await createCategoriesTxResultPromise
|
|
console.log('Successfully created categories!') // eslint-disable-line no-console
|
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
} catch (error) {
|
|
console.log(`Error creating categories: ${error}`) // eslint-disable-line no-console
|
|
} finally {
|
|
session.close()
|
|
driver.close()
|
|
}
|
|
}
|
|
|
|
;(async function () {
|
|
await createCategories()
|
|
})()
|