I am trying to update the skill endorsements for users, this my user schema
{
_id:'123456',
firstName:'xyz',
skills:[
{
title:'HTML',
endorsement:['12','13','14']
},
{
title:'CSS',
endorsement:[]
}
]
}
I want to push the id of user in endorsement array after finding that skill by its title, this the query's I'm using but its now working or me
1) update({_id:user_id,skills:{$elemMatch: {title:'HTML'}}},{ skills:{title:"HTML",$push:{endorsement: id}}})
2) update({_id:user_id,skills:{$elemMatch: {title:'HTML'}}},{ $push: {endorsement: id}})
Here user_id is the skill holder and id is the skill endorser.