Increment
Adds custom method .increment()
#109
.increment (criteria, field[, amount][, cb])
Increments the given field by amount (defaults to 1
). This can be used to generate sequencial numbers, more about this in OrientDB docs.
usage:
// Given a model Counter with attributes `name` and `value`
Counter.increment({ name: 'counter1' }, 'value', function (err, counter) {
console.log('counter1 has increased by 1 to:', counter.value);
});
// To decrement use negative numbers
Counter.increment({ name: 'counter1' }, 'value', -2)
.then(function (counter) {
console.log('counter1 haas decreased by 2 to:', counter.value);
});