Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is the 'updateMany' function of mongodb deprecated?

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.

like image 322
Syed Faizan Avatar asked Jan 18 '16 17:01

Syed Faizan


People also ask

What is updateMany in MongoDB?

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.


2 Answers

this worked for me

 db.collection.update({},{$set:{,is_expired:false}},{multi:true})
like image 114
Apoorv Avatar answered Oct 16 '22 18:10

Apoorv


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.

like image 29
gnerkus Avatar answered Oct 16 '22 16:10

gnerkus