Answer the question
In order to leave comments, you need to log in
MongoDB: Does update overwrite same values?
There is a code
db.test.test->insert ({_id: 1, key1: 'value1'})
db.test.test->update ({_id: 1}, {$set: {key1: 'value1'}})
Answer the question
In order to leave comments, you need to log in
Apparently, the record is not being made:
D:\MongoDB>mongo --verbose
MongoDB shell version: 2.6.3
...
> db.test.insert({_id:1, key1:"value1"})
WriteResult({ "nInserted" : 1 })
> db.test.update({_id:1}, {$set:{key1:"value1"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })
> db.test.update({_id:1}, {$set:{key1:"value2"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Well, how could they not find it there in black and white at the very beginning it is written
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question