Hi I try to find a solution to the placement of form data to the data collection MongoDB database, automatically add its own ID on such values: 2015/1, 2015/2, 2015/3 … … and so on.
He tried to use modules “collection2”, “simple-schema”, “autoform” but I found just as automatically add date:
// Force value to be current date (on server) upon insert
// and prevent updates thereafter.
createdAt: {
type: Date,
autoValue: function() {
if (this.isInsert) {
return new Date;
} else if (this.isUpsert) {
return {$setOnInsert: new Date};
} else {
this.unset(); // Prevent user from supplying their own value
}
}
}
Does anyone have an idea how to automatically add your own id to the collection of data.