I'm testing LokiJS in my browser. I want to save the db created as json file in same folder. But nothing happens. This is the code that i found online and i'm testing:
var db = new loki('test.json');
var db2 = new loki('test.json');
var users = db.addCollection('users');
users.insert({
name: 'joe'
});
users.insert({
name: 'john'
});
users.insert({
name: 'jack'
});
console.log(users.data);
db.saveDatabase();
db2.loadDatabase({}, function () {
var users2 = db2.getCollection('users')
console.log(users2.data);
});
What am i missing ? Thanks.