大佬教程收集整理的这篇文章主要介绍了Loki js 不在节点 js 中永久存储数据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我写了一个简单的nodeJs
访问者程序。这里我想存储这个程序的执行日期。执行是指使用node index.Js
命令运行这个程序。
第一次运行该程序时,它会将数据({execution-time: datE})存储到 db.Json 文件中。但下次运行该程序时,旧数据将被删除并插入新数据。
但我想保留所有以前的数据和新数据。
index.Js
const colLECTION = 'build';
const db_name = "db.Json";
const UPLOAD_PATH= "database";
const Loki = require("lokiJs");
const db = new Loki(`${UPLOAD_PATH}/${db_name}`);
const col = db.getCollection(ColLECTION) || db.addCollection(ColLECTION );
col.insert({'execution-date':new Date()})
db.saveDatabase();
console.log(`@R_172_10586@l number of execution of this program : ${Col.chain().data().length} `);
这里我得到以下结果
@R_172_10586@l number of execution of this program : 1 #first run
@R_172_10586@l number of execution of this program : 1 #second run
@R_172_10586@l number of execution of this program : 1 #third run
预期输出
@R_172_10586@l number of execution of this program :1 #first run
@R_172_10586@l number of execution of this program :2 #second run
@R_172_10586@l number of execution of this program :3 #third run
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的Loki js 不在节点 js 中永久存储数据全部内容,希望文章能够帮你解决Loki js 不在节点 js 中永久存储数据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。