Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在NodeJS中使用LokiJS时,我在寻找自动保存数据的完美解决方案时遇到了一些困难......
我从官方文档中尝试了一些东西,但它只是说 saveDB 不是一个函数。
请帮忙。
初始化新数据库时,您可以指定autosave和autoload参数:
autosave
autoload
let db = new loki('db.json', {autosave: true, autoload: true});
您还可以在进行任何更改后手动保存:
db.saveDatabase();