* Increment the value of one or more columns. This is done in the database, which means it does not use the values currently stored on the Instance. The increment is done using a
* Increment the value of one or more columns. This is done in the database, which means it does not use the values currently stored on the Instance. The increment is done using a
* ```sql
* ``` SET column = column + X WHERE foo = 'bar' ``` query. To get the correct value after an increment into the Instance you should do a reload.
* SET column = column + X WHERE foo = 'bar'
* ```
* query. To get the correct value after an increment into the Instance you should do a reload.
*
*
*```js
* ```js
* Model.increment('number', { where: { foo: 'bar' }) // increment number by 1
* // increment number by 1
* Model.increment(['number', 'count'], { by: 2, where: { foo: 'bar' } }) // increment number and count by 2
* @param {String|Array|Object} fields If a string is provided, that column is incremented by the value of `by` given in options. If an array is provided, the same is true for each column. If and object is provided, each column is incremented by the value given.
* @param {String|Array|Object} fields If a string is provided, that column is incremented by the value of `by` given in options. If an array is provided, the same is true for each column. If and object is provided, each column is incremented by the value given.
* @param {Object} options
* @param {Object} options
* @param {Object} options.where
* @param {Object} options.where
...
@@ -3009,6 +3012,36 @@ class Model {
...
@@ -3009,6 +3012,36 @@ class Model {
});
});
}
}
/**
* Decrement the value of one or more columns. This is done in the database, which means it does not use the values currently stored on the Instance. The decrement is done using a
* ```sql SET column = column - X WHERE foo = 'bar'``` query. To get the correct value after a decrement into the Instance you should do a reload.