我有一个插入查询:
Activity.insert ({
activityType: this.activityType,
bib: $("input#checkin").val(),
"legacy.eventId": Session.get("eventIdLegacy"),
checkpointNumber: Session.get("checkpointNumber")
});
目前,它使用消息
扼杀了“legacy.eventId”Exception while invoking method '/activity/insert' Error: key legacy.eventId must not contain '.'
插入嵌套的mongoldb字段的正确语法是什么?
答案 0 :(得分:1)
如果legacy
是对象数组,则可以将数据插入:
Activity.insert({
activityType: this.activityType,
bib: $("input#checkin").val(),
legacy: [
{ eventId: Session.get("eventIdLegacy") }
],
checkpointNumber: Session.get("checkpointNumber")
});
否则:
Activity.insert({
activityType: this.activityType,
bib: $("input#checkin").val(),
legacy: {
eventId: Session.get("eventIdLegacy")
},
checkpointNumber: Session.get("checkpointNumber")
});