2022-07-16 20:22:26 +00:00
|
|
|
let fs = require("fs");
|
2022-08-05 19:04:37 +00:00
|
|
|
class DB {
|
|
|
|
constructor(databaseFile) {
|
|
|
|
let _db;
|
|
|
|
if (fs.existsSync(databaseFile)) {
|
|
|
|
_db = JSON.parse(fs.readFileSync(databaseFile, "utf8"));
|
|
|
|
} else {
|
|
|
|
fs.writeFileSync(databaseFile, JSON.stringify({}));
|
|
|
|
_db = {};
|
|
|
|
}
|
2022-08-05 18:56:46 +00:00
|
|
|
this.v = _db
|
|
|
|
this.update = function() {
|
|
|
|
fs.writeFileSync(databaseFile, JSON.stringify(this.v));
|
|
|
|
}
|
|
|
|
}
|
2022-07-16 20:22:26 +00:00
|
|
|
}
|
2022-08-05 19:00:10 +00:00
|
|
|
exports.DB = DB;
|