node.js - mongodb 用findOneAndUpdate更新数据
PHP中文网
PHP中文网 2017-04-17 16:04:35
0
1
779

在使用nodejs操作mongodb时(我用的是monk这个库),使用findOneAndUpdate更新数据时,一条数据第一遍更新是成功的,但第二遍更新不成功,打印错误是:{ lastErrorObject: { updatedExisting: false, n: 0 },
value: null,
ok: 1 }
网上找了很久找不到解决方法,来请教各位大神是怎么回事

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
Ty80

According to the lastErrorObject you provided:

1. updatedExisting: false, indicating that the document has not been modified.
2. n: 0, indicating that the data has been modified to 0

Normal modification to data will return a value. This value is the modified document

From what you said, when updating the data, the corresponding document was not found according to the filter conditions, so the updte was not successful.

For reference.

Love MongoDB! Have Fun!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template