Just like below:
const loki=require('lokijs');
let blogData=new loki("./server/database/blogData.json",{ autoload: true,});
let users=blogData.addCollection("users");
let posts=blogData.addCollection("posts");
blogData.addCollection("others");
setInterval(() => {users.insert({name:Math.random()*30});}, 2000);
setInterval(() => {
console.log("time to save",blogData.saveDatabase(()=>{
console.log("manually saved")
}))
},10000)
And I wait.There printed "time to save", but no "saved" printed.
I tried set the saveDatabase directly as the "setInterval"'s callback,but it doesn't work. And I have set autosave on and autosavecallback.It doesn't work too.