0

字段“attributeMetaDataList”具有类似的参考

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

这对我不起作用。有什么帮助吗?

4

1 回答 1

0
db.Category.find({"path":/^Health/}).forEach(function(x){
  db.Category.update({_id:x._id},{$unset:{"attributeMetaDataList":1}})
})

它对我有用。

于 2013-01-22T10:42:46.757 回答