db.movieDetails.updateMany({
"tomato.consensus": null,
"imdb.votes":{$lt:10000},
"year":{$gte:2010,$lte:2013}},
{
$unset:{"tomato.consensus":""
}
})
When I typed the command above in the mongo
shell, I received an error that stated that updateMany
was not a valid function.
TypeError: Property 'updateMany' of object video.movieDetails is not a function at (shell):1:17
I checked the documentation and updateMany
is listed a valid function. I would like to know why I received the error.
The updateMany() method updates all the documents in MongoDB collections that match the given query. When you update your document, the value of the _id field remains unchanged. This method can also add new fields in the document.
this worked for me
db.collection.update({},{$set:{,is_expired:false}},{multi:true})
The updateMany
command has not been deprecated. You'll find the documentation for the command here: db.collection.updateMany.
You were unable to use the command because it was introduced in the 3.2
version of MongoDB. You need to install the 3.2
version to use the updateMany
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With