Reputation: 1130
I have an insert query:
Activity.insert ({
activityType: this.activityType,
bib: $("input#checkin").val(),
"legacy.eventId": Session.get("eventIdLegacy"),
checkpointNumber: Session.get("checkpointNumber")
});
Currently, it chokes on "legacy.eventId" with the message
Exception while invoking method '/activity/insert' Error: key legacy.eventId must not contain '.'
What is the correct syntax to insert into a nested mongoldb field?
Upvotes: 1
Views: 518
Reputation: 103305
If legacy
is an object array, you could insert the data as:
Activity.insert({
activityType: this.activityType,
bib: $("input#checkin").val(),
legacy: [
{ eventId: Session.get("eventIdLegacy") }
],
checkpointNumber: Session.get("checkpointNumber")
});
else:
Activity.insert({
activityType: this.activityType,
bib: $("input#checkin").val(),
legacy: {
eventId: Session.get("eventIdLegacy")
},
checkpointNumber: Session.get("checkpointNumber")
});
Upvotes: 1