Hello I have a document with some user records.
"profile":{
"records":[
{
"classId": "LngdsQfL",
"moduleId": "5CDEezDJ",
"sectionId": "nFMu3mwa",
"dateFinished": "",
"dateOpened": "2017-11-15T19:48:20.819Z"
},
{
"classId": "7Smq5sG",
"moduleId": "5CDEezDJ",
"sectionId": "nFMu3mwa",
"dateFinished": "",
"dateOpened": "2017-11-15T19:19:08.669Z"
}
]
}
But when I am trying to update the second record the query updates the first one. And the second one stays the same.
var classId= "7Smq5sG";
var moduleId = "5CDEezDJ";
var sectionId = "nFMu3mwa";
var date = new Date();
Users.update(
{ _id:Meteor.userId() ,
'profile.records.classId' : classId,
'profile.records.moduleId' : moduleId,
'profile.records.sectionId' : sectionId,
},{
$set : {
"profile.records.$.dateOpened": date
}
});
}
What am I missing?