I cannot for the life of me figure out why my call to findOneAndUpdate
does not update anything unless I handle the returned promise with .then()
. I don't care what the call returns so I don't bother to handle the promise.
This does not work:
MyModel.findOneAndUpdate({key: 'XXXXX'}, {$set: {status: 'complete'}})
This works:
MyModel.findOneAndUpdate({key: 'XXXXX'}, {$set: {status: 'complete'}}).then()
Appending a .then()
at the end certainly doesn't hurt me in any way, but I am simply curious as to why the call doesn't work without it. Shouldn't it still execute the query?
This guys seems to be asking the same question, but as of yet it's still unresolved: Why does MongoDB not update unless I call ".then res.json(...)" after findOneAndUpdate?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…