如果不存在(具有默认值),我想更新或插入活动:
我的JSON:
{"item" :
{"id":"031",
"activity":
[{"code":"1", "name": "activityA", "compt":"1"}
{"code":"2", "name": "activityB", "compt":"0"}]
}
类似的东西……
db.items.update({id:"id_in_param"},{activity.code:"code_in_param",activity.name:"name_in_param", $inc:{activity.compt:1}, $setOnInsert:{activity.compt:1}}, {upsert:true});