Javascript 如何将值从一个属性传递到同一集合的另一个属性?

Javascript 如何将值从一个属性传递到同一集合的另一个属性?,javascript,meteor,Javascript,Meteor,我的“作业”集合具有以下扩展属性: var job = _.extend(jobAttributes, { userId: user._id, author: user.profile.name.toLowerCase(), submitted: new Date(), commentsCount: 0, upvoters: [], votes: 10, apply: 0, tweets: 0

我的“作业”集合具有以下扩展属性:

   var job = _.extend(jobAttributes, {
      userId: user._id, 
      author: user.profile.name.toLowerCase(),
      submitted: new Date(),
      commentsCount: 0,
      upvoters: [],
      votes: 10,
      apply: 0,
      tweets: 0,
      views: 0,
      day1: 2,
      day2: 0
    });
我要做的是将值从“Day1”发送到“Day2”

我为此制作了一个“SyncedCron”

SyncedCron.add({
name: 'Update Example',
schedule: function(parser) {
    return parser.text('every 2 minutes');
},
job: function() {
    var one = this.day1;
    Jobs.update({'day2': one});
}
});
但我没有更新属性,而是出现了以下错误:

Error: Invalid modifier. Modifier must be an object.

问题在于
Jobs.update({'day2':one})

发件人:

collection.update(选择器、修饰符、[options]、[callback])


必须提供选择器和修饰符。

在插入自身时,我使用类似的方法基于另一个字段填充字段。 我已经定义了模式,如

Jobs = new Mongo.Collection("jobs");

Jobs.schema = new SimpleSchema({
  day1: {
    type: SimpleSchema.Integer,
  },
  day2: {
    type: Number,
    autoValue: function() {
      if (this.isInsert) {
        return this.siblingField("day1").value;
      }
    }
  }
});

Jobs.attachSchema(Jobs.schema);

当您在作业函数中使用“this”时,可能无法获得所需的上下文。您是否尝试只为它设置一个随机值,而不是从'this.day1'中获取它?我将其修改为'Jobs.update({u id:Jobs.{u id},{$set:{day2:9,day1:0});'你是对的,什么都没发生。我只想为集合.Jobs.update({u-id:Jobs.{u-id},{$set:{day2:9,day1:0})中的每个“项”设置一个值;没有,语法看起来是正确的。没有运气意味着仍然会犯同样的错误,或者什么都没有发生。我想做的是找到一种方法,将“属性值”传递给同一集合的另一个“属性”。你知道我该怎么做吗?例如,第1天到第2天的数据