1
我在更新記錄時遇到問題。我的文檔結構是這樣的:Mongodb增加對象的一部分
"_id" : "1141825507009",
"person" : [
{
"amount" : 25,
"id" : "1141825507009"
}
]
我想3遞增person.amount其中person.id爲1141825507009.那麼容易。 關於什麼:
Increment person.amount by 3 if person.id exist.
Add to person list with amount 3 and id 239something845 if person.id does not exist in list.
是兩個單獨的操作或單個要麼/或行動? – 2012-07-16 12:23:49
你正在使用哪個驅動程序? – Aaron 2012-07-16 12:49:06
@ BryceAtNetwork23我正在使用PHP驅動程序。我想在一個動作中這樣做:addtoset,而不是設置值增加它。 – ewooycom 2012-07-16 13:15:17