我尝试使用以下内容为auto increment id
添加sub-documents
:
db.users.update({"pup.avt.fto": var},{"$push":{"pup.$.cmn":{"txt": cmnt, {"id":{"$inc":1}}}}})
但它不起作用!
我做错了什么?
这是我得到的(使用Mongo的方)
如您所见,我想添加id
并增加它:
{
"adr": {
"wil": "15",
"com": "Azazga",
"sit": "http://peugeot.dz",
"cor": [
36.743954,
4.365041
]
},
"_id": "abdelouahab_al@yahoo.fr",
"pup": [
{
"avt": {
"fto": {
"$oid": "516ff3e03a5f3a0eec7c4e2b"
},
"ori": "portrait"
},
"cmn": [
{
"txt": "this is the comment that i want to add the increment id"
},
],
},
}