1

I have an object with this model:

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 });

the default options are:

this.options = [
    { 'key':'accepted','value':false },
    { 'key':'enable','value':false },
    ....
];

for change one of this options I make a query/update like this:

query['to_options.key'] = req.body.key;
update['to_options.$.value'] = req.body.value;

but how can I change more then one object?I need to make more then one query?

francesco.venica
  • 1,703
  • 2
  • 19
  • 54
  • This question seems to be closely related to yours http://stackoverflow.com/questions/29346460/mongoose-update-array-of-subdocuments – Sridhar Jan 31 '17 at 05:25

0 Answers0