- The `fieldName` property, used in associations with a foreign key object `(A.hasMany(B, { foreignKey: { ... }})`, has been renamed to `name` to avoid confusion with `field`.
- The `fieldName` property, used in associations with a foreign key object `(A.hasMany(B, { foreignKey: { ... }})`, has been renamed to `name` to avoid confusion with `field`.
- The naming of the join table entry for N:M association getters is now singular (like includes)
- The naming of the join table entry for N:M association getters is now singular (like includes)
- Signature of hooks has changed to pass options to all hooks
- Signature of hooks has changed to pass options to all hooks. Any hooks previously defined like `Model.beforeCreate(values)` now need to be `Model.beforeCreate(values, options)` etc.
- Results returned by hooks are ignored - changes to results by hooks should be made by reference
- Results returned by hooks are ignored - changes to results by hooks should be made by reference
-`Model.destroy()` signature has been changed from `(where, options)` to `(options)`, options now take a where parameter.
-`Model.destroy()` signature has been changed from `(where, options)` to `(options)`, options now take a where parameter.
- The syntax for `Model.findOrBuild` has changed, to be more in line with the rest of the library. `Model.findOrBuild(where, defaults);` becomes `Model.findOrBuild({ where: where, defaults: defaults });`.
# v2.0.0-dev13
# v2.0.0-dev13
We are working our way to the first 2.0.0 release candidate.
We are working our way to the first 2.0.0 release candidate.
* Find a row that matches the query, or build (but don't save) the row if none is found.
* Find a row that matches the query, or build (but don't save) the row if none is found.
* The successfull result of the promise will be (instance, initialized) - Make sure to use .spread()
* The successfull result of the promise will be (instance, initialized) - Make sure to use .spread()
*
*
* @param {Object} where A hash of search attributes. Note that this method differs from finders, in that the syntax is `{ attr1: 42 }` and NOT `{ where: { attr1: 42}}`. This may be subject to change in 2.0
* @param {Object} options
* @param {Object} [defaults] Default values to use if building a new instance
* @param {Object} options.where A hash of search attributes.
* @param {Object} [options] Options passed to the find call
* @param {Object} [options.defaults] Default values to use if building a new instance
* @deprecated The syntax is due for change, in order to make `where` more consistent with the rest of the API
* @param {Object} [options.transaction] Transaction to run query under
thrownewError('Missing where attribute in the options parameter passed to findOrCreate. Please note that the API has changed, and is now options (an object with where and defaults keys), queryOptions (transaction etc.)');