2016-05-13 11 views
0

Ich bin versuchen, meine ausgehende DB in Lokijs verwenden, aber meine autoloadcallback Dosis nicht mit console.log ('von add collection don') zu wissen, wenn es feuert, aber es nie Dosis und wenn ich versuche hinzuzufügen Daten db es nur nicht funktioniert, wenn ich meine Sammlung VariableLokijs autoloadcallbake nicht 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(); 
 
    }

lokal eingestellt

Antwort

1

Sie sind Optionen in einer dritten Variablen Einstellung, die nicht vorhanden ist, sollte es nur sein:

new loki(file, [options]); 

adapter ist eine Option, genau wie die anderen, wie folgt aus:

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"); 
      } 

     } 
    }); 

Prost

Verwandte Themen