1

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?

1 Answer 1

1

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")
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.