Update 'index.js'

This commit is contained in:
wumpus 2022-08-05 20:56:46 +02:00
parent 570795b832
commit f696c8579a

View File

@ -7,11 +7,13 @@ function loadDB(databaseFile) {
fs.writeFileSync(databaseFile, JSON.stringify({}));
_db = {};
}
return new Proxy(_db, {
set: function (target, key, value) {
target[key] = value;
fs.writeFileSync(databaseFile, JSON.stringify(target));
},
});
return class {
constructor() {
this.v = _db
this.update = function() {
fs.writeFileSync(databaseFile, JSON.stringify(this.v));
}
}
}
}
exports.loadDB = loadDB;