mongodbmongo-shell

Why do I get the error "Property 'updateMany' of object video.movieDetails is not a function"?


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.

I'm using MongoDB 3.0.2


Solution

  • You are unable to use the command because it was introduced in the 3.2 version of MongoDB. You need to install MongoDB 3.2 or newer to use the updateMany command.

    You can find the documentation for the updateMany command here: db.collection.updateMany.