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