const low = require('lowdb'); const FileSync = require('lowdb/adapters/FileSync'); var db = null; function db_init(db){ db.defaults({ chats:[]}).write(); } var dbc = function(name){ const db_file = "./db/"+name+".json"; var db = low(new FileSync(db_file)); db_init(db); return db; }; const schema = { recipe:{ id: "reciple_id", name:"recipe_name", ingredients:"recipe_ingredients", }, ingredient:{ id: "ingredient_id", name: "" } }; module.exports = function(name){ this.name = name; this.db = dbc(name); this.dump_db = function(obj){ return new Promise((resolve, reject)=>{ resolve(this.db.get("chats").value()); }); }; };