I have a model where only one record can have a 'current' property set to, for example, 1.
Is it possible for the beforeCreate
or beforeUpdate
to access the collection. Basically I want to do something like this:
afterUpdate: function (values, next) {
// If this value is current, reset all the others
if (values.current == 1) {
this.collection.update({
id: { '!': values.id }
}, {
current: 0
}, next);
}
}
What id don't know is what I can reliably use for this.collection
in the example above.
Thanks in advance.