自動保存オプションを使用して非常に基本的なlokijsのサンプルを試しましたが、データを保存できません...
私の間違いの考え?(これはhttps://github.com/techfort/LokiJS/wiki/LokiJS-persistence-and-adaptersにあるサンプルの適応です
PC (Windows) で最新バージョンの lokijs を使用して Node v10.14.2 を使用していますか?
const loki = require('lokijs');
var db = new loki('sandbox.db', {
autoload: true,
autoloadCallback : databaseInitialize,
autosave: true,
autosaveInterval: 4000
});
function databaseInitialize() {
var cu = db.getCollection("Users");
if (!cu) {
cu = db.addCollection("Users", {indices: ['name']});
}
if (!cu) {
var now = new Date();
try{
cu.insert({
name : "Mr X",
email : "Mr_x@gmail.com",
password : "xyz",
creation: now
});
}
catch(ex){
console.log("test exception: "+ ex.message);
}
}
}