mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
39 lines
892 B
JavaScript
39 lines
892 B
JavaScript
|
|
const utils = require('../utils/utils.js')
|
|
const dbtools = require('../utils/dbtools.js')
|
|
const dbStructPath = '../modules/api/apiDBStruct.json'
|
|
const usersDBPath = '../data/dbs/users.db'
|
|
|
|
let authDB
|
|
|
|
console.clear()
|
|
|
|
function CreateDB () {
|
|
const dbStruct = utils.ReadJSON(dbStructPath)
|
|
authDB = dbtools.GetDB(usersDBPath)
|
|
|
|
Object.keys(dbStruct).forEach((tableName) => {
|
|
const tableData = dbStruct[tableName]
|
|
dbtools.CreateTable(authDB, tableName, tableData.tableStruct, tableData.foreignKey)
|
|
})
|
|
|
|
try {
|
|
// TODO: fill with data
|
|
dbtools.Insert(authDB, 'users', {
|
|
pw: 2,
|
|
notes: 'hemnlo'
|
|
})
|
|
dbtools.Insert(authDB, 'users', {
|
|
pw: 1,
|
|
notes: 'hemnlo'
|
|
})
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
|
|
// Object.keys(dbStruct).forEach((key) => {
|
|
// console.log(key)
|
|
// console.log(dbtools.TableInfo(authDB, key))
|
|
// })
|
|
}
|
|
CreateDB()
|