ruscomap/dbHandler.js
2024-06-30 22:56:19 +02:00

36 lines
No EOL
922 B
JavaScript

import sqlite3 from 'sqlite3'
import { open } from 'sqlite'
async function createTableRusco(){
await db.exec(
"CREATE TABLE rusco ( id INTEGER PRIMARY KEY AUTOINCREMENT, name text NOT NULL, description text, iamge text, x REAL NOT NULL, y REAL NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL);"
)
}
async function createDB(){
}
async function checkTableExists(){
const db = await Promise.all(
open({
filename: '/ruscodb',
driver: sqlite3.Database
}))
await db.exec('.tables')
}
module.exports = {
initDB: async function () {
fs.access('ruscodb', fs.constants.F_OK, (err) => {
if (err) {
createDB()
} else {
checkTableExists()
}
});
},
addDB: async function () {
// whatever
}
};