With virtualfields included, the fields with autoValue do not make into the database on an insert. If I remove the virtualFields, the autoValue fields are fine. Sample code:
Businesses = new Meteor.Collection2('businesses', {
schema: {
businessName: {
type: String,
label: "Business name",
max: 50
},
owner: {
type: String,
label: "Owner name",
max: 50,
optional: true
},
// autoValue fields:
createdAt: {
type: Date,
autoValue: function() {
if (this.isInsert) {
return new Date();
}
},
denyUpdate: true
},
createdBy: {
type: String,
autoValue: function() {
if (this.isInsert) {
return Meteor.userId();
}
},
denyUpdate: true
},
updatedAt: {
type: Date,
autoValue: function() {
if (this.isUpdate) {
return new Date();
}
},
denyInsert: true,
optional: true
},
// Soft delete
deletedAt: {
type: Date,
optional: true
}
},
// Virtual field code, e.g.
virtualFields: {
neighborhood: function(biz) {
return "some hood";
}
}
});