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":""
    }
})

当我在 mongo shell 中键入上面的命令时,我收到一条错误消息,指出 updateMany 不是一个有效的函数。

TypeError: Property 'updateMany' of object video.movieDetails is not a function at (shell):1:17

我检查了文档,updateMany 列出了一个有效函数。我想知道为什么会收到错误消息。

updateMany 命令尚未弃用。您可以在此处找到该命令的文档:db.collection.updateMany.

您无法使用该命令,因为它是在 MongoDB 的 3.2 版本中引入的。您需要安装 3.2 版本才能使用 updateMany 命令。

这对我有用

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