数据结构(原数据)
{
"id":"upwmup7",
"questionItems": [
{
"questionTitle": "示例题目",
"single": true,
"answers": [
{
"content": "第一个答案",
"ischeck": false,
"name": 0,
"number":0
},
{
"content": "第二个答案",
"ischeck": false,
"name": 1,
"number":0
}
],
}]
}
我的数据库操作语句
var id = 'upwmup7'
var _ = db.command
db.collection('QuestionnaireItems').where({
id:id
}).update({
data: {
questionItems:[
{
answers: [
{
number: _.inc(1)
},
{
number: _.inc(2)
}
]
}
]
}
})
我得到的结果
{
"id": "upwmup7",
"questionItems": [
{
"answers": [
{},
{}
]
}
]
}
怎么写才能让原数据中的字段自增呢?求各位大神指教,卡了半个星期了