我想从文档中删除 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")
}}
答案 0 :(得分:1)
db.coll.update({"_id" : ObjectId("5201cadc5b4da1f65a000001")}, {$unset: {Path :
1}})
您必须为 $ unset 运算符赋值 1
将coll
替换为您的收藏名称