【问题标题】:Meteor Update returns 1 document updated but the field value doesn´t changeMeteor Update 返回 1 个文档已更新,但字段值未更改
【发布时间】:2018-01-18 08:03:39
【问题描述】:

没有错误...只是不更新​​文档。最奇怪的是,更新在控制台中返回 1,因为更新了文档的数量,但基础 Mongo 中的值没有改变。

在服务器中:

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

在客户端:

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

文档存在,我可以对其执行 findOne() 并获得文档。但是 _id 的更新不会改变值。

【问题讨论】:

    标签: mongodb reactjs meteor


    【解决方案1】:

    OMG...问题是架构中的默认值...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-31
      • 1970-01-01
      • 2017-05-28
      • 2021-10-07
      • 1970-01-01
      • 2017-06-14
      • 1970-01-01
      相关资源
      最近更新 更多