0
我嘗試在Lokijs中使用我現有的數據庫,但是我的autoloadcallback不會使用console.log('from add collection don')知道它什麼時候會啓動,但它永遠不會劑量,當我嘗試添加時數據DB它失敗,只有當我在本地Lokijs autoloadcallbake not woking
var user = null
db = new loki("myuser.json",{adapter: adapter}, {
autosave: true,
autosaveInterval: 5000,
autoload: true,
autoloadCallback: function(){
db_ready = true;
console.log('from add collection don')
if(db.getCollection("myaccount") == null){
myusers = db.addCollection("myaccount");
}
}
});
function py_userlogin(username,password,islogin){
myusers.insert({
username:username,
password:password,
islogin:islogin
},function(err,don){
console.log(JSON.stringify(err) + JSON.stringify(don))
});
console.log(myusers.data);
db.saveDatabase();
}