I want to update Collection
on Collection-Hook
like this
// Collection
Collection.Customer = new Mongo.Collection("customer");
// Schema
Schema.Customer = new SimpleSchema({
name: {
type: String,
label: "Name",
max: 200
},
gender: {
type: String,
label: "Gender"
},
dob: {
type: String,
label: "Date of Birth"
},
telephone: {
type: String,
label: "Telephone",
optional: true
}
});
// Attach schema
Collection.Customer.attachSchema(Schema.Customer);
And then I want to update Customer Name
on Hoook
but get error with validate
Collection.Other.after.update(function (userId, doc, fieldNames, modifier, options) {
modifier.$set = modifier.$set || {};
Collection.Customer.update({}, {$set: {name: 'Rabbit'}}, {multi: true})
});
How to solve this?