我有一个这个模型的对象:
var schema = new db.Schema({
user : { type: db.Schema.ObjectId, ref: 'user' },
friend: { type: db.Schema.ObjectId, ref: 'user' },
options : [option],
created_on: Date
});
var option = new db.Schema({
key: String,
value: String
},{ _id : false });
默认选项为:
this.options = [
{ 'key':'accepted','value':false },
{ 'key':'enable','value':false },
....
];
要更改其中一个选项,我会像这样进行查询/更新:
query['to_options.key'] = req.body.key;
update['to_options.$.value'] = req.body.value;
但是如何更改多个对象?我需要进行多个查询?