Reactib
Reactib

Reputation: 85

Meteor Update returns 1 document updated but the field value doesn´t change

No error... just doesn't update the document. The weirdest thing is that the update returns 1 in console, as quantity of documents updated, but the value in the base Mongo did not change.

In the server:

export const closeCard = new ValidatedMethod({
  name: 'BoardCard.close',
  validate: new SimpleSchema({
   id : { type: String
             , regEx: SimpleSchema.RegEx.Id
             },
  solved: {type: Boolean}
  }).validator(),
  run(oneCard) {

    BoardCards.update(oneCard.id, {
      $set: { solved: ! oneCard.solved},
    });
  },
});

In the client:

tarjeta = {id : this.props.card._id, solved: this.props.card.solved}
  Meteor.call('BoardCard.close', tarjeta, (error, response) => {
      if (error) {   
        console.log(error)           
      }})

The document exists, i can do a findOne() of it and i get the document. But the update by _id doesn't change the value.

Upvotes: 0

Views: 308

Answers (1)

Reactib
Reactib

Reputation: 85

OMG... the problem was the default value in the schema...

Upvotes: 1

Related Questions