【发布时间】:2017-06-13 02:19:57
【问题描述】:
我正在尝试使用简单模式创建一个对象数组。在此示例中,一个人有一个由各个职位填充的 careerHistory 对象。我不知道如何插入和更新对象数组。它只是错误。我可以让它工作的唯一方法是明确的,例如。 'careerHistory.position.1.company'.
我正在使用:
- 流星
- 简单模式
- reactjs
- collection2-core
路径:mongodb
const ProfileCandidateSchema = new SimpleSchema({
userId: {
type: String,
regEx: SimpleSchema.RegEx.Id
},
careerHistory: { type: Array, optional: true },
'careerHistory.position': { type: Object, optional: true },
'careerHistory.position.$': { type: Object, optional: true },
'careerHistory.position.$.company': { type: String, optional: true },
'careerHistory.position.$.title': { type: String, optional: true }
});
路径:updateForm.js
ProfileCandidate.update(id, { $set: {
'careerHistory.position.company': this.state['position.company'],
'careerHistory.position.title': this.state['position.title'],
}
});
【问题讨论】:
标签: meteor simple-schema