Reputation: 180
I have this extended attributes for my 'Jobs' collection:
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
});
What I'm trying to do is send the value from 'Day1' to 'Day2'
I made a 'SyncedCron' for this
SyncedCron.add({
name: 'Update Example',
schedule: function(parser) {
return parser.text('every 2 minutes');
},
job: function() {
var one = this.day1;
Jobs.update({'day2': one});
}
});
But instead of updating the attribute, I got this error:
Error: Invalid modifier. Modifier must be an object.
Upvotes: 2
Views: 153
Reputation: 1853
I use something like this to populate field based on another field while insert itself. I have defined schema such as..
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);
Upvotes: 1
Reputation: 12874
The problem is with Jobs.update({'day2': one});
.
From documentation:
collection.update(selector, modifier, [options], [callback])
selector and modifier has to be provided.
Upvotes: 2