0

我想从文档中删除Path对象。我尝试使用$unset运算符,但它需要我不必提供的值。有没有办法从文档中删除整个子文档?

{
    "Address" : {
        "Country" : "temp",
        "City" : "temp",
        "Street" : "temp",
        "House" : "temp",
        "Apartment" : "temp"
    },
    "Birthday" : {
        "Date" : {
            "Day" : "temp",
            "Moth" : "temp",
            "Year" : "temp"
        }
    },
    "ConnectionStatus" : "Offline",
    "DisplayName" : "temp",
    "Email" : "temp",
    "FirstName" : "temp",
    "LastName" : "temp",
    "Password" : "temp",
    "Path" : {
        "Start" : {
            "Longtitude" : 400,
            "Latitude" : 300
        },
        "End" : {
            "Longtitude" : 500,
            "Latitude" : 400
        },
        "Milestones" : [ 
            {
                "Longtitude" : 420,
                "Latitude" : 320
            }, 
            {
                "Longtitude" : 450,
                "Latitude" : 350
            }, 
            {
                "Longtitude" : 480,
                "Latitude" : 380
            }
        ]
    },
    "ProgressStatus" : "Safe",
    "_id" : ObjectId("5201cadc5b4da1f65a000001")
}}
4

1 回答 1

1

db.coll.update({"_id" : ObjectId("5201cadc5b4da1f65a000001")}, {$unset: {Path : 1}})

您必须给$unset运算符一个值1

替换coll为您的收藏名称

于 2013-08-07T06:23:31.283 回答