字段'属性MetaData List'具有类似
的引用, "path" : "Health & Personal Care > Health > Health Aids > Bathroom Aids & Safety > Bathtub Rails", "attributeMetaDataList" : [ {
"$ref" : "AttributeMetadata",
"$id" : ObjectId("50726bd4e4b0adf08145e4f1")
}, {
"$ref" : "AttributeMetadata",
"$id" : ObjectId("50726bd4e4b0adf08145e4f2")
}, {
"$ref" : "AttributeMetadata",
"$id" : ObjectId("50726bd4e4b0adf08145e4f3")
}, {
"$ref" : "AttributeMetadata",
"$id" : ObjectId("50726bd4e4b0adf08145e4f4")
}, {
"$ref" : "AttributeMetadata",
"$id" : ObjectId("50726bd4e4b0adf08145e4f5")
} ]
我想通过循环删除此引用。
我用过,
db.Category.find({"path": /Health & Personal Care/}).forEach(function(x){
x.attributeMetaDataList=$unset
}
)
这对我不起作用。任何帮助?
答案 0 :(得分:0)
db.Category.find({"path":/^Health/}).forEach(function(x){
db.Category.update({_id:x._id},{$unset:{"attributeMetaDataList":1}})
})
它为我工作。