I create Collection Extend
like this
class BaseCollection extends Mongo.Collection {
constructor(name, opts) {
super(name, opts)
}
update(selector, modifier, ...rest) {
modifier.$set = modifier.$set || {}
const result = super.update(selector, modifier, ...rest)
return result
}
}
------
const Employees = new BaseCollection('employees')
And then I try to update
// Method
export const updateEmployee = new ValidatedMethod({
name: 'app.updateEmployee',
mixins: [CallPromiseMixin],
validate: null,
run(doc) {
if (Meteor.isServer) {
return Employees.update({ _id: doc._id }, { $set: doc })
}
},
})
Get error, but data is updated
Exception while invoking method 'app.updateEmployee' Error: key $set must not start with '$'