mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-22 10:45:56 +02:00
* Work on User & user db
This commit is contained in:
parent
7a3e375f5d
commit
c6e6c1562d
3 changed files with 193 additions and 48 deletions
|
@ -5,11 +5,12 @@ var conf = require('./config.js');
|
|||
var sqlite3 = require('sqlite3');
|
||||
var paths = require('path');
|
||||
|
||||
exports.initializeDatabases = initializeDatabases;
|
||||
exports.user = user;
|
||||
// database handles
|
||||
var dbs = {};
|
||||
|
||||
// db handles
|
||||
var user;
|
||||
exports.initializeDatabases = initializeDatabases;
|
||||
|
||||
exports.dbs = dbs;
|
||||
|
||||
function getDatabasePath(name) {
|
||||
return paths.join(conf.config.paths.db, name + '.sqlite3');
|
||||
|
@ -17,15 +18,15 @@ function getDatabasePath(name) {
|
|||
|
||||
function initializeDatabases() {
|
||||
// :TODO: this will need to change if more DB's are added
|
||||
user = new sqlite3.Database(getDatabasePath('user'));
|
||||
dbs.user = new sqlite3.Database(getDatabasePath('user'));
|
||||
|
||||
user.serialize(function onSerialized() {
|
||||
dbs.user.serialize(function onSerialized() {
|
||||
createUserTables();
|
||||
});
|
||||
}
|
||||
|
||||
function createUserTables() {
|
||||
user.run(
|
||||
dbs.user.run(
|
||||
'CREATE TABLE IF NOT EXISTS user (' +
|
||||
' id INTEGER PRIMARY KEY,' +
|
||||
' user_name VARCHAR NOT NULL,' +
|
||||
|
@ -33,7 +34,9 @@ function createUserTables() {
|
|||
');'
|
||||
);
|
||||
|
||||
user.run(
|
||||
// :TODO: create FK on delete/etc.
|
||||
|
||||
dbs.user.run(
|
||||
'CREATE TABLE IF NOT EXISTS user_property (' +
|
||||
' user_id INTEGER NOT NULL,' +
|
||||
' prop_name VARCHAR NOT NULL,' +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue