我尝试添加一个auto increment id
使用sub-documents
它:
db.users.update({"pup.avt.fto": var},{"$push":{"pup.$.cmn":{"txt": cmnt, {"id":{"$inc":1}}}}})
但它不起作用!
我究竟做错了什么?
这是我得到的(用过Mongo的Fang)
如您所见,我想添加一个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"
},
],
},
}