这是我的 mongodb 文档。
"_id" : ObjectId("5123731f2763c9682a000001"),
"created_on" : ISODate("2013-02-19T12:42:07.835Z"),
"currentLogin" : ISODate("2013-02-22T06:03:25.603Z"),
"email" : "xxx@test.com",
"extraPhotos" : 0,
"reqmail" : [ ],
"isActivated" : true,
"lastLogin" : ISODate("2013-02-20T05:42:15.359Z"),
"linkedAccounts" : [
{
"birthday" : "11/01/1984",
"email" : "testingxxx234@gmail.com",
"expiresIn" : "5184000",
"expiryMailNotifFlag" : -1,
"extraPhotos" : 0,
"fetchFromDate" : null,
"fetchOrder" : "oldest",
"fetchUntilDate" : "04/11/2014",
"locale" : "en_US",
"optIn" : true,
"timezone" : "5.5",
"userID" : "100000207309657"
}
],
"maxLinkedAccounts" : 4,
"name" : "venu wale",
"notifications" : [
{
"_id" : ObjectId("51275fb7389b85f222000001"),
"type" : "limitUsed",
"message" : "Account limit is used",
"accID" : "100000207309657",
"date" : ISODate("2013-02-22T12:08:23.419Z")
},
{
"_id" : ObjectId("51275fe8389b85f222000002"),
"type" : "limitUsed",
"message" : "Account limit is used",
"accID" : "100000207309657",
"date" : ISODate("2013-02-22T12:09:12.385Z")
},
{
"_id" : ObjectId("51276020389b85f222000003"),
"type" : "limitUsed",
"message" : "Account limit is used",
"accID" : "100000207309657",
"date" : ISODate("2013-02-22T12:10:08.275Z")
},
{
"_id" : ObjectId("5127605d389b85f222000004"),
"type" : "limitUsed",
"message" : "Account limit is used",
"accID" : "100000207309657",
"date" : ISODate("2013-02-22T12:11:09.946Z")
},
{
"_id" : ObjectId("51276097389b85f222000005"),
"type" : "limitUsed",
"message" : "Account limit is used",
"accID" : "100000207309657",
"date" : ISODate("2013-02-22T12:12:07.384Z")
},
{
"_id" : ObjectId("512760d2389b85f222000006"),
"type" : "limitUsed",
"message" : "Account limit is used",
"accID" : "100000207309657",
"date" : ISODate("2013-02-22T12:13:06.933Z")
}
],
"password" : "638cfc167e8431c01227e4f113ec9427821b12493ed6fd3",
"phone" : "5555555555",
"photo_updated_time" : 1361341819,
"photosProcessed" : 15,
"photosToProcess" : 400,
"plan" : {
"type" : "photoOnly"
},
"salt" : "af8ab2f5866642f03d31aa3f4a24e25e287bedc7",
"updated_on" : ISODate("2013-02-19T12:42:07.835Z")
我想从通知数组中删除任何一个对象。我正在使用这个查询。
db.users.update({phone:'5555555555'},{$unset:{notifications:{$elemMatch:{_id:ObjectId('51276020389b85f222000003')}}}})
但它不起作用。