* This class represents an single instance, a database column. You might see it referred to as both DAO and instance.
* This class represents an single instance, a database row. You might see it referred to as both DAO and instance.
*
* DAO instances operate with the concept of a `dataValues` property, which stores the actual values represented by this DAO. By default, the values from dataValues can also be accessed directly from the DAO, that is:
* ```js
...
...
@@ -18,7 +18,7 @@ module.exports = (function() {
* instance.getDataValue('field')
* ```
* However, if getters and/or setters are defined for `field` they will be invoked, instead of returning the value from `dataValues`.
*
* @see {Sequelize#define} Sequelize#define for more information about getters and setters
* 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 DAO. The increment is done using a
```sql
SET column = column + X
```
query. To get the correct value after an increment into the DAO you should do a reload.
```js
instance.increment('number') increment number by 1
instance.increment(['number', 'count'], { by: 2 }) increment number and count by 2
instance.increment({ answer: 42, tries: 1}, { by: 1 }) increment answer by 42, and tries by 1. `by` is ignore, since each column has its own value
```
* ```sql
* SET column = column + X
* ```
* query. To get the correct value after an increment into the DAO you should do a reload.
*
*```js
* instance.increment('number') increment number by 1
* instance.increment(['number', 'count'], { by: 2 }) increment number and count by 2
* instance.increment({ answer: 42, tries: 1}, { by: 1 }) increment answer by 42, and tries by 1. `by` is ignore, since each column has its own value
* ```
*
* @see {DAO#reload}
* @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
...
...
@@ -742,17 +742,17 @@ instance.increment({ answer: 42, tries: 1}, { by: 1 }) increment answer by 42, 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 DAO. The decrement is done using a
```sql
SET column = column - X
```
query. To get the correct value after an decrement into the DAO you should do a reload.
```js
instance.decrement('number') decrement number by 1
instance.decrement(['number', 'count'], { by: 2 }) decrement number and count by 2
instance.decrement({ answer: 42, tries: 1}, { by: 1 }) decrement answer by 42, and tries by 1. `by` is ignore, since each column has its own value
```
* 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 DAO. The decrement is done using a
* ```sql
* SET column = column - X
* ```
* query. To get the correct value after an decrement into the DAO you should do a reload.
*
* ```js
* instance.decrement('number') decrement number by 1
* instance.decrement(['number', 'count'], { by: 2 }) decrement number and count by 2
* instance.decrement({ answer: 42, tries: 1}, { by: 1 }) decrement answer by 42, and tries by 1. `by` is ignore, since each column has its own value
* ```
*
* @see {DAO#reload}
* @param {String|Array|Object} fields If a string is provided, that column is decremented 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 decremented by the value given
...
...
@@ -790,6 +790,12 @@ instance.decrement({ answer: 42, tries: 1}, { by: 1 }) decrement answer by 42, a
returnthis.increment(fields,countOrOptions)
}
/**
* Check whether all values of this and `other` DAO are the same
*
* @param {DAO} other
* @return {Boolean} true if the two DAOs have the same values
*/
DAO.prototype.equals=function(other){
varresult=true
...
...
@@ -804,19 +810,30 @@ instance.decrement({ answer: 42, tries: 1}, { by: 1 }) decrement answer by 42, a
returnresult
}
/**
* Check if this is eqaul to one of `others` by calling equals
*
* @param {Array} others
* @return {Boolean} true if at least one of the DAOs in others has the same values as this
* An object of different query types. This is used when doing raw queries (sequlize.query). If no type is provided to .query, sequelize will try to guess the correct type based on your SQL. This might not always work if you query is formatted in a special way
* @param {Function} [attributes.column.set] Provide a custom setter for this column. Use this.getDataValue(String) and this.setDataValue(String, Value) to manipulate the underlying values.
* @param {Object} [options] These options are merged with the options provided to the Sequelize constructor
* @param {Object} [options.defaultScope] Define the default search scope to use for this model. Scopes have the same form as the options passed to find / findAll
* @param {Object} [options.scopes] More scopes, defined in the same way as defaultScope above. See `DAOFactory.scope` for more information about how scopes are defined, and what you can do with them
* @param {Boolean} [options.omitNull] Don't persits null values. This means that all columns with null values will not be saved
* @param {Boolean} [options.timestamps=true] Handle createdAt and updatedAt timestamps
* @param {Boolean} [options.paranoid=false] Calling destroy will not delete the model, but instead set a deletedAt timestamp if this is true. Needs timestamps=true to work