-
-
Save HariantoAtWork/df836d029767d8cbc1222e2569c7bb57 to your computer and use it in GitHub Desktop.
LokiJS - save to disk and reload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var loki = require('lokijs'), | |
db = new loki('test.json'), | |
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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment