数据库如图2,目前fruits为空,我执行updae后
居然没有在原纪录的基础之上修改,,,也是醉了
附上NEDB github 地址 https://github.com/louischatriot/nedb
数据库如图2,目前fruits为空,我执行updae后
居然没有在原纪录的基础之上修改,,,也是醉了
附上NEDB github 地址 https://github.com/louischatriot/nedb
这有两句话
If the document does not contain an _id field, NeDB will automatically generated one for you (a 16-characters alphanumerical string). The _id of a document, once set, cannot be modified.
Note: the _id is automatically indexed with a unique constraint, no need to call ensureIndex on it.
我觉得是_id
必须是唯一的,而且最好不要自己设置,最后在update的时候,最好不要用_id为条件
Nedb对数据库进行操作的时候,其实是在文本的末尾进行的追加。它自己会定时的压缩数据,数据压缩后才会把后面的数据替换前面的数据。你可以直接调用db.persistence.compactDatafile()这个函数来强制压缩同步,或是把定时压缩的时间改短也行db.persistence.setAutocompactionInterval(interval)
3 回答2.6k 阅读✓ 已解决
1 回答958 阅读✓ 已解决
2 回答1.2k 阅读
1 回答1.1k 阅读✓ 已解决
2 回答637 阅读✓ 已解决
2 回答1.7k 阅读
2 回答1.1k 阅读
你是把数据库文件打开看的吧,请不要这样做。只需要按照常规的方式去读取,是会取到正确的数据的。