Collection2更新功能过滤掉密钥

时间:2017-06-21 05:23:21

标签: mongodb meteor simple-schema meteor-collection2

我的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
                }
        }})
  });

0 个答案:

没有答案