This is an overview of the structure of my collection:
{
profile: {
first_name: 'Plop',
surname: 'Plopette',
...
},
medical_history: {
significant_illnesses: [
'Asthma',
'Diabetes'
],
...
}
}
How do I access and update one of the items in the medical_history.significant_illnesses
array?
What I have is failing miserably:
Patients.update(Session.get("current_patient"), {
$push: {
"medical_history.significant_surgeries.surgeryIndex": $(event.target).val().trim()
}
});
Note, surgeryIndex
is dynamic so I can't hard-code anything.
The update code above produces this error:
Exception while simulating the effect of invoking '/patients/update'
errorClass {
error: 409,
reason: "MinimongoError: can't append to array using string field name [surgeryIndex]",
details: undefined, message: "MinimongoError: can't append to array using string field name [surgeryIndex] [409]",
errorType: "Meteor.Error"}