These are chat archives for Automattic/mongoose

1st
Mar 2019
vijaykaimal3881
@vijaykaimal3881
Mar 01 15:30
Hi,
vijaykaimal3881
@vijaykaimal3881
Mar 01 15:35

We have tried to update ranking array with follwing query,We just need to update points with 35 for all array elements, it is not working for me.

UserModel.update({
'userId': 148,
'ranking.sportId': {$in:[1,2,3,4]}
}, {
$set: {
'ranking.$.points': 35
}
},{multi:true});


{
"_id" : ObjectId("5b1e67f7966be059daf25a27"),
"userId" : 148,
"updatedAt" : ISODate("2019-02-13T08:00:01.250Z"),
"createdAt" : ISODate("2018-06-11T12:15:51.607Z"),
"ranking" : [
{
"sportId" : 1,
"rank" : 2,
"subRank" : 1,
"points" : 80.0,
},
{
"sportId" : 2,
"rank" : 2,
"subRank" : 2,
"points" : 80,
},
{
"points" : 115.0,
"subRank" : 0,
"rank" : 2,
"sportId" : 4,
},
{
"points" : 130.0,
"subRank" : 1,
"rank" : 2,
"sportId" : 3
}
],
"groupId" : 0,
}

vijaykaimal3881
@vijaykaimal3881
Mar 01 15:40
Its updating first element of the array, how can we update all? any idea?