简体   繁体   English

mongodb的'updateMany'函数是否已弃用?

[英]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. 当我在mongo shell中键入上面的命令时,我收到一条错误,指出updateMany不是有效函数。

TypeError: Property 'updateMany' of object video.movieDetails is not a function at (shell):1:17 TypeError:对象video.movi​​eDetails的属性'updateMany'不是(shell):1:17的函数

I checked the documentation and updateMany is listed a valid function. 我检查了文档,并列出了updateMany一个有效的函数。 I would like to know why I received the error. 我想知道为什么会收到错误消息。

The updateMany command has not been deprecated. updateMany命令尚未被弃用。 You'll find the documentation for the command here: db.collection.updateMany . 您可以在此处找到该命令的文档: db.collection.updateMany

You were unable to use the command because it was introduced in the 3.2 version of MongoDB. 您无法使用该命令,因为该命令是在MongoDB的3.2版本中引入的。 You need to install the 3.2 version to use the updateMany command. 您需要安装3.2版本才能使用updateMany命令。

这对我有用

 db.collection.update({},{$set:{,is_expired:false}},{multi:true})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM