猫鼬中的ArrayFilter [英] ArrayFilter in mongoose
问题描述
将查询转换为节点.在哪个版本中,arrayfilter可以在猫鼬中工作,或者如何在节点应用程序中运行它们
Convert the query into node. In which version arrayfilter work in mongoose or how can run these in node app
db.getCollection('student').update(
{
"_id": ObjectId('5a377d62d21a3025a3c3aa49')
},
{
$set: {
"examples.$[i].isDeleted": true,
"examples.$[i].updatedAt": new Date(),
"updatedAt": new Date()
}
},
{
arrayFilters: [
{
"i._id": {
$in:[
ObjectId("5a377d62d21a3025a3c3aa4d"),
ObjectId("5a377d62d21a3025a3c3aa4c")
]
}
}
],
multi: true
}
)
https://docs.mongodb.com/manual/参考/运算符/更新/位置过滤/
推荐答案
根据版本 MongoDB 3.6的注释 https://docs.mongodb.com/manual/release-notes/3.6/
(@兼容驱动程序)以访问mongodb 3.6功能,需要使用节点驱动程序3.x.
(@ Compatible Drivers) to get access to mongodb 3.6 features it is required to use the node driver 3.x.
似乎驱动程序处于RC状态(目前为止是此答案). https://github.com/mongodb/node-mongodb-native/releases
It seems that the driver is in RC state (as of the time being of this answer). https://github.com/mongodb/node-mongodb-native/releases
正因如此,猫鼬可能仍在等待开始使用它. https://github.com/Automattic/mongoose/blob/master/package. json
And as such, probably, mongoose is still waiting to start using it. https://github.com/Automattic/mongoose/blob/master/package.json
因此,您必须等到这些东西整理好之后,或者您当然可以尝试自行整理这些东西,直到正式改编为止.
So you have to wait until these things are arranged or of course you can try to wire things up by your self until the official adaptation is done.
-更新-
现在可以正常工作了.
这篇关于猫鼬中的ArrayFilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!