我的MongoDB,collection2更新函数不断抛出错误After filtering out keys, not in the schema, your modifier is now empty
。我被告知我的架构不正确,但是,我阅读了文档,据我所知,我已经按照建议实现了架构。
我的simple-schema看起来像是:
const ProfileCandidateSchema = new SimpleSchema({
userId: {
type: String,
regEx: SimpleSchema.RegEx.Id
},
careerHistoryPositions: { type: Array, optional: true },
'careerHistoryPositions.$': { type: Object, optional: true },
'careerHistoryPositions.$.uniqueId': { type: String, optional: true },
'careerHistoryPositions.$.company': { type: String, optional: true },
'careerHistoryPositions.$.title': { type: String, optional: true }
});
我的更新功能基于collection2:
const updatePosition = this.state.careerHistoryPositions.map((position) => {
ProfileCandidate.update(this.state.profileCandidateCollectionId, {$set: {
'careerHistoryPositions': {
'company': position.company,
'title': position.title,
'uniqueId': position.uniqueId
}
}})
});