bp123
bp123

Reputation: 3417

Collection2 update function filters out keys

My MongoDB, collection2 update function keeps throwing the error After filtering out keys, not in the schema, your modifier is now empty. I've been told that my schema isn't correct, however, I read the documentation and as far as I can tell I've implemented the schema as recommended.

My simple-schema looks like:

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

My update function based on collection2:

const updatePosition = this.state.careerHistoryPositions.map((position) => {    
ProfileCandidate.update(this.state.profileCandidateCollectionId, {$set: {
          'careerHistoryPositions': {
                  'company': position.company,
                  'title': position.title,
                  'uniqueId': position.uniqueId
                }
        }})
  });

Upvotes: 0

Views: 13

Answers (0)

Related Questions