$[] (positional-all)
update operator has been added in mongodb version 3.6. but it is not working in mongoose.
I want to update all the elements of allTasks
array of a particular user, whose paid : 0
to paid :1
The query which i am using is :
User.update({
_id: userId,
"allTasks.paid":0
},{
$set : {
"allTasks.$[].paid":1
}
})
UserSchema
var UserSchema = mongoose.Schema({
allTasks: [{
paid: Number // 0: unpaid, 1: paid
//other fields
}],
//other fields
});
The above given query is not working, can anyone tell me, if i am missing something, or doing something wrong?