javascript - updateOne deleting my data -
alright, i've been tinkering night , have sleep i'm asking here. why updateone
deleting data when should updating it?
db.collection('users').updateone({"name":"bob"}, {"age":"20"}, (e,i) => { console.log(i); });
i.result.ok
prints 1
, when go search bob
after doing this, data gone entirely, vanished.
my first question why happening, second how can update, since apparently isn't way it.
i can run find({"name":"bob"}) fine before hand, data exist before running this.
after, gone. please, blood pressure getting way high.
try following:-
you need use $set
update specific fields. {}
give blank, if there no find query.
db.collection('users').updateone({"name":"bob"},{$set: {"age":"20"} });
to answers, refer mongodb-update.
hope hep solving problem.
Comments
Post a Comment