我有以下文档结构
{
assets : {
type : [
{
type : spread
scene : [
{
....
},
{
....
}
]
}
]
}
}
所以我想在“scene”数组中添加新元素,并在同一文件中添加“spread”类型的匹配条件
我如何编写相同的Mongo Update查询?
答案 0 :(得分:0)
以下是示例数组
{
assets : {
type : [
{
type : spread
scene : [
{
....
},
{
....
}
]
}
]
}
}
参考链接 MongoDB & Meteor - Query to push into nested array does not work, no error thrown
查询在场景数组中插入新元素是
db.PhotostoryDesigner.update(
{
"photostoryId":"123",
"assets.type.type":"spreads"
},
{"$push": {
'assets.type.$.scene':{"$each":[
{
"scene_id": "1",
"name": "Ad hoc 1",
"spread": [
{
"spreadId": "7725",
"name": "PAGE 1-2",
"asset": []
}
]
}
]}}
}
);