mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2026-04-28 03:07:38 +02:00
prettier 4 tabwidth
This commit is contained in:
@@ -4,38 +4,38 @@ const dbtools = require('../../dist/utils/dbtools.js').default // eslint-disable
|
||||
const { v4: uuidv4 } = require('uuid') // eslint-disable-line
|
||||
|
||||
const dbStructPaths = [
|
||||
{ structPath: '../modules/api/usersDBStruct.json', name: 'users.db' },
|
||||
{ structPath: '../modules/api/msgsDbStruct.json', name: 'msgs.db' },
|
||||
{ structPath: '../modules/api/usersDBStruct.json', name: 'users.db' },
|
||||
{ structPath: '../modules/api/msgsDbStruct.json', name: 'msgs.db' },
|
||||
]
|
||||
|
||||
dbStructPaths.forEach((data) => {
|
||||
const { structPath, name } = data
|
||||
createDB(structPath, name)
|
||||
const { structPath, name } = data
|
||||
createDB(structPath, name)
|
||||
})
|
||||
|
||||
function createDB(path, name) {
|
||||
const dbStruct = utils.ReadJSON(path)
|
||||
const db = dbtools.GetDB(`./${name}`)
|
||||
db.pragma('synchronous = OFF')
|
||||
const dbStruct = utils.ReadJSON(path)
|
||||
const db = dbtools.GetDB(`./${name}`)
|
||||
db.pragma('synchronous = OFF')
|
||||
|
||||
Object.keys(dbStruct).forEach((tableName) => {
|
||||
const tableData = dbStruct[tableName]
|
||||
dbtools.CreateTable(
|
||||
db,
|
||||
tableName,
|
||||
tableData.tableStruct,
|
||||
tableData.foreignKey
|
||||
)
|
||||
})
|
||||
printDb(db, dbStruct)
|
||||
db.close()
|
||||
Object.keys(dbStruct).forEach((tableName) => {
|
||||
const tableData = dbStruct[tableName]
|
||||
dbtools.CreateTable(
|
||||
db,
|
||||
tableName,
|
||||
tableData.tableStruct,
|
||||
tableData.foreignKey
|
||||
)
|
||||
})
|
||||
printDb(db, dbStruct)
|
||||
db.close()
|
||||
|
||||
logger.Log('Done')
|
||||
logger.Log('Done')
|
||||
}
|
||||
|
||||
function printDb(db, dbStruct) {
|
||||
Object.keys(dbStruct).forEach((key) => {
|
||||
console.log(dbtools.TableInfo(db, key))
|
||||
console.log(dbtools.SelectAll(db, key))
|
||||
})
|
||||
Object.keys(dbStruct).forEach((key) => {
|
||||
console.log(dbtools.TableInfo(db, key))
|
||||
console.log(dbtools.SelectAll(db, key))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user