不要怂,就是干,撸起袖子干!

Commit 3d2dd9c5 by Jan Aagaard Meier

[ci skip] docs(generate) Apply api doc changes from #5311

1 parent 3e5b8772
<a name="belongstomany"></a>
# Mixin BelongsToMany
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L41)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L41)
Many-to-many association with a join table.
......@@ -31,7 +31,7 @@ In the API reference below, replace `Assocation(s)` with the actual name of your
<a name="getassociations"></a>
## `getAssociations([options])` -> `Promise.<Array.<Instance>>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L209)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L209)
Get everything currently associated with this, using an optional where clause.
......@@ -49,7 +49,7 @@ Get everything currently associated with this, using an optional where clause.
<a name="setassociations"></a>
## `setAssociations([newAssociations], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L219)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L219)
Set the associated models by passing an array of instances or their primary keys. Everything that it not in the passed array will be un-associated.
......@@ -66,7 +66,7 @@ Set the associated models by passing an array of instances or their primary keys
<a name="addassociations"></a>
## `addAssociations([newAssociations], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L229)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L229)
Associate several instances with this.
......@@ -83,7 +83,7 @@ Associate several instances with this.
<a name="addassociation"></a>
## `addAssociation([newAssociation], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L239)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L239)
Associate one instance with this.
......@@ -100,7 +100,7 @@ Associate one instance with this.
<a name="createassociation"></a>
## `createAssociation([values], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L248)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L248)
Create a new instance of the associated model and associate it with this.
......@@ -116,7 +116,7 @@ Create a new instance of the associated model and associate it with this.
<a name="removeassociation"></a>
## `removeAssociation([oldAssociated], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L257)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L257)
Un-associate the instance.
......@@ -132,7 +132,7 @@ Un-associate the instance.
<a name="removeassociations"></a>
## `removeAssociations([oldAssociated], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L266)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L266)
Un-associate several instances.
......@@ -148,7 +148,7 @@ Un-associate several instances.
<a name="hasassociation"></a>
## `hasAssociation([instance], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L275)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L275)
Check if an instance is associated with this.
......@@ -164,7 +164,7 @@ Check if an instance is associated with this.
<a name="hasassociations"></a>
## `hasAssociations([instances], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L284)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L284)
Check if all instances are associated with this.
......@@ -180,7 +180,7 @@ Check if all instances are associated with this.
<a name="countassociations"></a>
## `countAssociations([options])` -> `Promise.<Int>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L294)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to-many.js#L294)
Count everything currently associated with this, using an optional where clause.
......
<a name="belongsto"></a>
# Mixin BelongsTo
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to.js#L17)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to.js#L17)
One-to-one association
......@@ -10,7 +10,7 @@ In the API reference below, replace `Assocation` with the actual name of your as
<a name="getassociation"></a>
## `getAssociation([options])` -> `Promise.<Instance>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to.js#L83)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to.js#L83)
Get the associated instance.
......@@ -27,7 +27,7 @@ Get the associated instance.
<a name="setassociation"></a>
## `setAssociation([newAssociation], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to.js#L93)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to.js#L93)
Set the associated model.
......@@ -44,7 +44,7 @@ Set the associated model.
<a name="createassociation"></a>
## `createAssociation([values], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to.js#L102)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/belongs-to.js#L102)
Create a new instance of the associated model and associate it with this.
......
<a name="hasmany"></a>
# Mixin HasMany
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L17)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L17)
One-to-many association
......@@ -10,7 +10,7 @@ In the API reference below, replace `Association(s)` with the actual name of you
<a name="getassociations"></a>
## `getAssociations([options])` -> `Promise.<Array.<Instance>>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L104)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L104)
Get everything currently associated with this, using an optional where clause.
......@@ -28,7 +28,7 @@ Get everything currently associated with this, using an optional where clause.
<a name="setassociations"></a>
## `setAssociations([newAssociations], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L114)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L114)
Set the associated models by passing an array of instances or their primary keys. Everything that is not in the passed array will be un-associated
......@@ -45,7 +45,7 @@ Set the associated models by passing an array of instances or their primary keys
<a name="addassociations"></a>
## `addAssociations([newAssociations], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L124)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L124)
Associate several instances with this.
......@@ -62,7 +62,7 @@ Associate several instances with this.
<a name="addassociation"></a>
## `addAssociation([newAssociation], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L134)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L134)
Associate one instance with this.
......@@ -79,7 +79,7 @@ Associate one instance with this.
<a name="createassociation"></a>
## `createAssociation([values], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L143)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L143)
Create a new instance of the associated model and associate it with this.
......@@ -95,7 +95,7 @@ Create a new instance of the associated model and associate it with this.
<a name="removeassociation"></a>
## `removeAssociation([oldAssociated], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L152)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L152)
Un-associate the instance.
......@@ -111,7 +111,7 @@ Un-associate the instance.
<a name="removeassociations"></a>
## `removeAssociations([oldAssociatedArray], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L161)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L161)
Un-associate several instances.
......@@ -127,7 +127,7 @@ Un-associate several instances.
<a name="hasassociation"></a>
## `hasAssociation([instance], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L170)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L170)
Check if an instance is associated with this.
......@@ -143,7 +143,7 @@ Check if an instance is associated with this.
<a name="hasassociations"></a>
## `hasAssociations([instances], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L179)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L179)
Check if all instances are associated with this.
......@@ -159,7 +159,7 @@ Check if all instances are associated with this.
<a name="countassociations"></a>
## `countAssociations([options])` -> `Promise.<Int>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L189)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-many.js#L189)
Count everything currently associated with this, using an optional where clause.
......
<a name="hasone"></a>
# Mixin HasOne
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-one.js#L17)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-one.js#L17)
One-to-one association
......@@ -11,7 +11,7 @@ This is almost the same as `belongsTo` with one exception. The foreign key will
<a name="getassociation"></a>
## `getAssociation([options])` -> `Promise.<Instance>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-one.js#L78)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-one.js#L78)
Get the associated instance.
......@@ -28,7 +28,7 @@ Get the associated instance.
<a name="setassociation"></a>
## `setAssociation([newAssociation], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-one.js#L87)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-one.js#L87)
Set the associated model.
......@@ -44,7 +44,7 @@ Set the associated model.
<a name="createassociation"></a>
## `createAssociation([values], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-one.js#L96)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/has-one.js#L96)
Create a new instance of the associated model and associate it with this.
......
<a name="associations"></a>
# Mixin Associations
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/mixin.js#L89)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/mixin.js#L89)
Creating associations in sequelize is done by calling one of the belongsTo / hasOne / hasMany / belongsToMany functions on a model (the source), and providing another model as the first argument to the function (the target).
......@@ -81,7 +81,7 @@ Note how we also specified `constraints: false` for profile picture. This is bec
<a name="hasone"></a>
## `hasOne(target, [options])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/mixin.js#L131)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/mixin.js#L131)
Creates an association between this (the source) and the provided target. The foreign key is added on the target.
......@@ -105,7 +105,7 @@ Example: `User.hasOne(Profile)`. This will add userId to the profile table.
<a name="belongsto"></a>
## `belongsTo(target, [options])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/mixin.js#L149)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/mixin.js#L149)
Creates an association between this (the source) and the provided target. The foreign key is added on the source.
......@@ -130,7 +130,7 @@ Example: `Profile.belongsTo(User)`. This will add userId to the profile table.
<a name="hasmany"></a>
## `hasMany(target, [options])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/mixin.js#L166)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/mixin.js#L166)
Creates a 1:m association between this (the source) and the provided target. The foreign key is added on the target.
......@@ -155,7 +155,7 @@ Example: `User.hasMany(Profile)`. This will add userId to the profile table.
<a name="belongstomany"></a>
## `belongsToMany(target, [options])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/mixin.js#L245)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/associations/mixin.js#L245)
Create an N:M association with a join table.
......
<a name="datatypes"></a>
# Class DataTypes
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L57)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L57)
A convenience class holding commonly used data types. The datatypes are used when defining a new model using `Sequelize.define`, like this:
```js
......@@ -47,7 +47,7 @@ sequelize.define('model', {
<a name="string"></a>
## `STRING()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L109)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L109)
A variable length string. Default length 255
......@@ -57,7 +57,7 @@ Available properties: `BINARY`
<a name="char"></a>
## `CHAR()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L151)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L151)
A fixed length string. Default length 255
......@@ -67,7 +67,7 @@ Available properties: `BINARY`
<a name="text"></a>
## `TEXT()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L170)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L170)
An (un)limited length text column. Available lengths: `tiny`, `medium`, `long`
......@@ -75,7 +75,7 @@ An (un)limited length text column. Available lengths: `tiny`, `medium`, `long`
<a name="integer"></a>
## `INTEGER()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L258)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L258)
A 32 bit integer.
......@@ -85,7 +85,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="bigint"></a>
## `BIGINT()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L283)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L283)
A 64 bit integer.
......@@ -95,7 +95,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="float"></a>
## `FLOAT()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L307)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L307)
Floating point number (4-byte precision). Accepts one or two arguments for precision
......@@ -105,7 +105,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="real"></a>
## `REAL()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L332)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L332)
Floating point number (4-byte precision). Accepts one or two arguments for precision
......@@ -115,7 +115,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="double"></a>
## `DOUBLE()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L350)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L350)
Floating point number (8-byte precision). Accepts one or two arguments for precision
......@@ -125,7 +125,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="decimal"></a>
## `DECIMAL()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L368)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L368)
Decimal number. Accepts one or two arguments for precision
......@@ -135,7 +135,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="boolean"></a>
## `BOOLEAN()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L397)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L397)
A boolean / tinyint column, depending on dialect
......@@ -143,7 +143,7 @@ A boolean / tinyint column, depending on dialect
<a name="time"></a>
## `TIME()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L416)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L416)
A time column
......@@ -151,7 +151,7 @@ A time column
<a name="date"></a>
## `DATE()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L427)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L427)
A datetime column
......@@ -159,7 +159,7 @@ A datetime column
<a name="dateonly"></a>
## `DATEONLY()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L476)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L476)
A date only column
......@@ -167,7 +167,7 @@ A date only column
<a name="hstore"></a>
## `HSTORE()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L492)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L492)
A key / value column. Only available in postgres.
......@@ -175,7 +175,7 @@ A key / value column. Only available in postgres.
<a name="json"></a>
## `JSON()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L507)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L507)
A JSON string column. Only available in postgres.
......@@ -183,7 +183,7 @@ A JSON string column. Only available in postgres.
<a name="jsonb"></a>
## `JSONB()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L526)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L526)
A pre-processed JSON data column. Only available in postgres.
......@@ -191,7 +191,7 @@ A pre-processed JSON data column. Only available in postgres.
<a name="now"></a>
## `NOW()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L538)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L538)
A default value of the current timestamp
......@@ -199,7 +199,7 @@ A default value of the current timestamp
<a name="blob"></a>
## `BLOB()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L548)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L548)
Binary storage. Available lengths: `tiny`, `medium`, `long`
......@@ -207,7 +207,7 @@ Binary storage. Available lengths: `tiny`, `medium`, `long`
<a name="range"></a>
## `RANGE()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L603)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L603)
Range types are data types representing a range of values of some element type (called the range's subtype).
Only available in postgres.
......@@ -217,7 +217,7 @@ See {@link http://www.postgresql.org/docs/9.4/static/rangetypes.html|Postgres do
<a name="uuid"></a>
## `UUID()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L653)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L653)
A column storing a unique universal identifier. Use with `UUIDV1` or `UUIDV4` for default values.
......@@ -225,7 +225,7 @@ A column storing a unique universal identifier. Use with `UUIDV1` or `UUIDV4` fo
<a name="uuidv1"></a>
## `UUIDV1()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L669)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L669)
A default unique universal identifier generated following the UUID v1 standard
......@@ -233,7 +233,7 @@ A default unique universal identifier generated following the UUID v1 standard
<a name="uuidv4"></a>
## `UUIDV4()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L689)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L689)
A default unique universal identifier generated following the UUID v4 standard
......@@ -241,7 +241,7 @@ A default unique universal identifier generated following the UUID v4 standard
<a name="virtual"></a>
## `VIRTUAL()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L746)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L746)
A virtual value that is not stored in the DB. This could for example be useful if you want to provide a default value in your model that is returned to the user but not stored in the DB.
......@@ -287,7 +287,7 @@ __Aliases:__ NONE
<a name="enum"></a>
## `ENUM()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L762)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L762)
An enumeration. `DataTypes.ENUM('value', 'another value')`.
......@@ -295,7 +295,7 @@ An enumeration. `DataTypes.ENUM('value', 'another value')`.
<a name="array"></a>
## `ARRAY()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L786)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L786)
An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in postgres.
......@@ -303,15 +303,60 @@ An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in
<a name="geometry"></a>
## `GEOMETRY()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L823)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L869)
A geometry datatype represents two dimensional spacial objects.
A column storing Geometry information.
Only available in PostgreSQL (with PostGIS) or MySQL.
In MySQL, allowable Geometry types are 'POINT', 'LINESTRING', 'POLYGON'.
When using, GeoJSON is accepted as input and returned as output.
In PostGIS, the GeoJSON is parsed using the PostGIS function `ST_GeomFromGeoJSON`.
In MySQL it is parsed using the function `GeomFromText`.
Therefore, one can just follow the [GeoJSON spec](http://geojson.org/geojson-spec.html) for handling geometry objects. See the following examples:
```js
// Create a new point:
var point = { type: 'Point', coordinates: [39.807222,-76.984722]};
User.create({username: 'username', geometry: point }).then(function(newUser) {
...
});
// Create a new linestring:
var line = { type: 'LineString', 'coordinates': [ [100.0, 0.0], [101.0, 1.0] ] };
User.create({username: 'username', geometry: line }).then(function(newUser) {
...
});
// Create a new polygon:
var polygon = { type: 'Polygon', coordinates: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]};
User.create({username: 'username', geometry: polygon }).then(function(newUser) {
...
});
// Create a new point with a custom SRID:
var point = {
type: 'Point',
coordinates: [39.807222,-76.984722],
crs: { type: 'name', properties: { name: 'EPSG:4326'} }
};
User.create({username: 'username', geometry: point }).then(function(newUser) {
...
});
```
***
<a name="geography"></a>
## `GEOGRAPHY()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/data-types.js#L848)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/data-types.js#L894)
A geography datatype represents two dimensional spacial objects in an elliptic coord system.
......
<a name="deferrable"></a>
## `Deferrable()` -> `object`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L39)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/deferrable.js#L39)
A collection of properties related to deferrable constraints. It can be used to
make foreign key constraints deferrable and to set the constraints within a
......@@ -36,7 +36,7 @@ sequelize.transaction({
<a name="initially_deferred"></a>
## `INITIALLY_DEFERRED()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L59)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/deferrable.js#L59)
A property that will defer constraints checks to the end of transactions.
......@@ -44,7 +44,7 @@ A property that will defer constraints checks to the end of transactions.
<a name="initially_immediate"></a>
## `INITIALLY_IMMEDIATE()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L76)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/deferrable.js#L76)
A property that will trigger the constraint checks immediately
......@@ -52,7 +52,7 @@ A property that will trigger the constraint checks immediately
<a name="not"></a>
## `NOT()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L95)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/deferrable.js#L95)
A property that will set the constraints to not deferred. This is
the default in PostgreSQL and it make it impossible to dynamically
......@@ -62,7 +62,7 @@ defer the constraints within a transaction.
<a name="set_deferred"></a>
## `SET_DEFERRED(constraints)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L114)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/deferrable.js#L114)
A property that will trigger an additional query at the beginning of a
transaction which sets the constraints to deferred.
......@@ -78,7 +78,7 @@ transaction which sets the constraints to deferred.
<a name="set_immediate"></a>
## `SET_IMMEDIATE(constraints)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L135)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/deferrable.js#L135)
A property that will trigger an additional query at the beginning of a
transaction which sets the constraints to immediately.
......
<a name="errors"></a>
# Class Errors
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L11)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L11)
Sequelize provides a host of custom error classes, to allow you to do easier debugging. All of these errors are exposed on the sequelize object and the sequelize constructor.
All sequelize errors inherit from the base JS error object.
......@@ -9,7 +9,7 @@ All sequelize errors inherit from the base JS error object.
<a name="baseerror"></a>
## `new BaseError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L20)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L20)
The Base Error all Sequelize Errors inherit from.
__Aliases:__ Error
......@@ -18,7 +18,7 @@ __Aliases:__ Error
<a name="validationerror"></a>
## `new ValidationError(message, [errors])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L41)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L41)
Validation Error. Thrown when the sequelize validation has failed. The error contains an `errors` property,
which is an array with 1 or more ValidationErrorItems, one for each validation that failed.
......@@ -37,7 +37,7 @@ __Extends:__ BaseError
<a name="errors"></a>
## `errors`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L49)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L49)
An array of ValidationErrorItems
......@@ -45,7 +45,7 @@ An array of ValidationErrorItems
<a name="get"></a>
## `get(path)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L70)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L70)
Gets all validation error items for the path / field specified.
......@@ -60,7 +60,7 @@ Gets all validation error items for the path / field specified.
<a name="databaseerror"></a>
## `new DatabaseError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L84)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L84)
A base class for all database related errors.
......@@ -70,7 +70,7 @@ __Extends:__ BaseError
<a name="parent"></a>
## `parent`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L92)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L92)
The database specific error which triggered this one
......@@ -78,7 +78,7 @@ The database specific error which triggered this one
<a name="sql"></a>
## `sql`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L98)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L98)
The SQL that triggered the error
......@@ -86,7 +86,7 @@ The SQL that triggered the error
<a name="message"></a>
## `message()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L104)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L104)
The message from the DB.
......@@ -94,7 +94,7 @@ The message from the DB.
<a name="fields"></a>
## `fields()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L109)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L109)
The fields of the unique constraint
......@@ -102,7 +102,7 @@ The fields of the unique constraint
<a name="value"></a>
## `value()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L114)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L114)
The value(s) which triggered the error
......@@ -110,7 +110,7 @@ The value(s) which triggered the error
<a name="index"></a>
## `index()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L119)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L119)
The name of the index that triggered the error
......@@ -118,7 +118,7 @@ The name of the index that triggered the error
<a name="timeouterror"></a>
## `new TimeoutError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L127)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L127)
Thrown when a database query times out because of a deadlock
......@@ -128,7 +128,7 @@ __Extends:__ DatabaseError
<a name="uniqueconstrainterror"></a>
## `new UniqueConstraintError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L138)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L138)
Thrown when a unique constraint is violated in the database
......@@ -138,7 +138,7 @@ __Extends:__ DatabaseError
<a name="foreignkeyconstrainterror"></a>
## `new ForeignKeyConstraintError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L157)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L157)
Thrown when a foreign key constraint is violated in the database
......@@ -148,7 +148,7 @@ __Extends:__ DatabaseError
<a name="exclusionconstrainterror"></a>
## `new ExclusionConstraintError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L177)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L177)
Thrown when an exclusion constraint is violated in the database
......@@ -158,7 +158,7 @@ __Extends:__ DatabaseError
<a name="validationerroritem"></a>
## `new ValidationErrorItem(message, type, path, value)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L201)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L201)
Validation Error Item
Instances of this class are included in the `ValidationError.errors` property.
......@@ -177,7 +177,7 @@ Instances of this class are included in the `ValidationError.errors` property.
<a name="connectionerror"></a>
## `new ConnectionError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L213)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L213)
A base class for all connection related errors.
......@@ -187,7 +187,7 @@ __Extends:__ BaseError
<a name="parent"></a>
## `parent`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L220)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L220)
The connection specific error which triggered this one
......@@ -195,7 +195,7 @@ The connection specific error which triggered this one
<a name="connectionrefusederror"></a>
## `new ConnectionRefusedError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L230)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L230)
Thrown when a connection to a database is refused
......@@ -205,7 +205,7 @@ __Extends:__ ConnectionError
<a name="accessdeniederror"></a>
## `new AccessDeniedError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L241)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L241)
Thrown when a connection to a database is refused due to insufficient privileges
......@@ -215,7 +215,7 @@ __Extends:__ ConnectionError
<a name="hostnotfounderror"></a>
## `new HostNotFoundError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L252)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L252)
Thrown when a connection to a database has a hostname that was not found
......@@ -225,7 +225,7 @@ __Extends:__ ConnectionError
<a name="hostnotreachableerror"></a>
## `new HostNotReachableError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L263)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L263)
Thrown when a connection to a database has a hostname that was not reachable
......@@ -235,7 +235,7 @@ __Extends:__ ConnectionError
<a name="invalidconnectionerror"></a>
## `new InvalidConnectionError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L274)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L274)
Thrown when a connection to a database has invalid values for any of the connection parameters
......@@ -245,7 +245,7 @@ __Extends:__ ConnectionError
<a name="connectiontimedouterror"></a>
## `new ConnectionTimedOutError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L285)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L285)
Thrown when a connection to a database times out
......@@ -255,7 +255,7 @@ __Extends:__ ConnectionError
<a name="instanceerror"></a>
## `new InstanceError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L296)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/errors.js#L296)
Thrown when a some problem occurred with Instance methods (see message for details)
......
<a name="hooks"></a>
# Mixin Hooks
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L39)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L39)
Hooks are function that are called before and after (bulk-) creation/updating/deletion and validation. Hooks can be added to you models in three ways:
......@@ -38,7 +38,7 @@ Model.afterBulkUpdate(function () {})
<a name="addhook"></a>
## `addHook(hooktype, [name], fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L160)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L160)
Add a hook to the model
......@@ -56,7 +56,7 @@ __Aliases:__ hook
<a name="removehook"></a>
## `removeHook(hookType, name)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L179)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L179)
Remove hook from the model
......@@ -72,7 +72,7 @@ Remove hook from the model
<a name="hashook"></a>
## `hasHook(hookType)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L205)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L205)
Check whether the mode has any hooks of this type
......@@ -88,7 +88,7 @@ __Aliases:__ hasHooks
<a name="beforevalidate"></a>
## `beforeValidate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L218)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L218)
A hook that is run before validation
......@@ -104,7 +104,7 @@ A hook that is run before validation
<a name="aftervalidate"></a>
## `afterValidate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L225)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L225)
A hook that is run after validation
......@@ -120,7 +120,7 @@ A hook that is run after validation
<a name="beforecreate"></a>
## `beforeCreate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L232)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L232)
A hook that is run before creating a single instance
......@@ -136,7 +136,7 @@ A hook that is run before creating a single instance
<a name="aftercreate"></a>
## `afterCreate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L239)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L239)
A hook that is run after creating a single instance
......@@ -152,7 +152,7 @@ A hook that is run after creating a single instance
<a name="beforedestroy"></a>
## `beforeDestroy(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L248)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L248)
A hook that is run before destroying a single instance
......@@ -169,7 +169,7 @@ __Aliases:__ beforeDelete
<a name="afterdestroy"></a>
## `afterDestroy(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L257)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L257)
A hook that is run after destroying a single instance
......@@ -186,7 +186,7 @@ __Aliases:__ afterDelete
<a name="beforerestore"></a>
## `beforeRestore(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L265)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L265)
A hook that is run before restoring a single instance
......@@ -202,7 +202,7 @@ A hook that is run before restoring a single instance
<a name="afterrestore"></a>
## `afterRestore(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L273)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L273)
A hook that is run after restoring a single instance
......@@ -218,7 +218,7 @@ A hook that is run after restoring a single instance
<a name="beforeupdate"></a>
## `beforeUpdate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L280)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L280)
A hook that is run before updating a single instance
......@@ -234,7 +234,7 @@ A hook that is run before updating a single instance
<a name="afterupdate"></a>
## `afterUpdate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L287)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L287)
A hook that is run after updating a single instance
......@@ -250,7 +250,7 @@ A hook that is run after updating a single instance
<a name="beforebulkcreate"></a>
## `beforeBulkCreate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L294)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L294)
A hook that is run before creating instances in bulk
......@@ -266,7 +266,7 @@ A hook that is run before creating instances in bulk
<a name="afterbulkcreate"></a>
## `afterBulkCreate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L301)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L301)
A hook that is run after creating instances in bulk
......@@ -282,7 +282,7 @@ A hook that is run after creating instances in bulk
<a name="beforebulkdestroy"></a>
## `beforeBulkDestroy(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L310)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L310)
A hook that is run before destroying instances in bulk
......@@ -299,7 +299,7 @@ __Aliases:__ beforeBulkDelete
<a name="afterbulkdestroy"></a>
## `afterBulkDestroy(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L319)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L319)
A hook that is run after destroying instances in bulk
......@@ -316,7 +316,7 @@ __Aliases:__ afterBulkDelete
<a name="beforebulkrestore"></a>
## `beforeBulkRestore(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L327)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L327)
A hook that is run before restoring instances in bulk
......@@ -332,7 +332,7 @@ A hook that is run before restoring instances in bulk
<a name="afterbulkrestore"></a>
## `afterBulkRestore(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L335)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L335)
A hook that is run after restoring instances in bulk
......@@ -348,7 +348,7 @@ A hook that is run after restoring instances in bulk
<a name="beforebulkupdate"></a>
## `beforeBulkUpdate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L342)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L342)
A hook that is run before updating instances in bulk
......@@ -364,7 +364,7 @@ A hook that is run before updating instances in bulk
<a name="afterbulkupdate"></a>
## `afterBulkUpdate(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L349)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L349)
A hook that is run after updating instances in bulk
......@@ -380,7 +380,7 @@ A hook that is run after updating instances in bulk
<a name="beforefind"></a>
## `beforeFind(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L356)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L356)
A hook that is run before a find (select) query
......@@ -396,7 +396,7 @@ A hook that is run before a find (select) query
<a name="beforefindafterexpandincludeall"></a>
## `beforeFindAfterExpandIncludeAll(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L363)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L363)
A hook that is run before a find (select) query, after any { include: {all: ...} } options are expanded
......@@ -412,7 +412,7 @@ A hook that is run before a find (select) query, after any { include: {all: ...}
<a name="beforefindafteroptions"></a>
## `beforeFindAfterOptions(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L370)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L370)
A hook that is run before a find (select) query, after all option parsing is complete
......@@ -428,7 +428,7 @@ A hook that is run before a find (select) query, after all option parsing is com
<a name="afterfind"></a>
## `afterFind(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L377)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L377)
A hook that is run after a find (select) query
......@@ -444,7 +444,7 @@ A hook that is run after a find (select) query
<a name="beforedefine"></a>
## `beforeDefine(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L384)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L384)
A hook that is run before a define call
......@@ -460,7 +460,7 @@ A hook that is run before a define call
<a name="afterdefine"></a>
## `afterDefine(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L391)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L391)
A hook that is run after a define call
......@@ -476,7 +476,7 @@ A hook that is run after a define call
<a name="beforeinit"></a>
## `beforeInit(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L398)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L398)
A hook that is run before Sequelize() call
......@@ -492,7 +492,7 @@ A hook that is run before Sequelize() call
<a name="afterinit"></a>
## `afterInit(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L405)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L405)
A hook that is run after Sequelize() call
......@@ -508,7 +508,7 @@ A hook that is run after Sequelize() call
<a name="beforesync"></a>
## `beforeSync(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L412)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L412)
A hook that is run before Model.sync call
......@@ -524,7 +524,7 @@ A hook that is run before Model.sync call
<a name="aftersync"></a>
## `afterSync(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L419)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L419)
A hook that is run after Model.sync call
......@@ -540,7 +540,7 @@ A hook that is run after Model.sync call
<a name="beforebulksync"></a>
## `beforeBulkSync(name, fn)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L426)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L426)
A hook that is run before sequelize.sync call
......@@ -556,7 +556,7 @@ A hook that is run before sequelize.sync call
<a name="afterbulksync"></a>
## `afterBulkSync`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/hooks.js#L434)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/hooks.js#L434)
A hook that is run after sequelize.sync call
......
<a name="instance"></a>
# Class Instance
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L85)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L85)
This class represents an single instance, a database row. You might see it referred to as both Instance and instance. You should not
instantiate the Instance class directly, instead you access it using the finder and creation methods on the model.
......@@ -26,7 +26,7 @@ Accessing properties directly or using `get` is preferred for regular use, `getD
<a name="isnewrecord"></a>
## `isNewRecord` -> `Boolean`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L98)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L98)
Returns true if this instance has not yet been persisted to the database
......@@ -34,7 +34,7 @@ Returns true if this instance has not yet been persisted to the database
<a name="model"></a>
## `Model()` -> `Model`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L107)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L107)
Returns the Model the instance was created from.
......@@ -47,7 +47,7 @@ Returns the Model the instance was created from.
<a name="sequelize"></a>
## `sequelize()` -> `Sequelize`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L116)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L116)
A reference to the sequelize instance
......@@ -60,7 +60,7 @@ A reference to the sequelize instance
<a name="where"></a>
## `where()` -> `Object`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L126)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L126)
Get an object representing the query for this instance, use with `options.where`
......@@ -68,7 +68,7 @@ Get an object representing the query for this instance, use with `options.where`
<a name="getdatavalue"></a>
## `getDataValue(key)` -> `any`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L150)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L150)
Get the value of the underlying data value
......@@ -83,7 +83,7 @@ Get the value of the underlying data value
<a name="setdatavalue"></a>
## `setDataValue(key, value)`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L160)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L160)
Update the underlying data value
......@@ -99,7 +99,7 @@ Update the underlying data value
<a name="get"></a>
## `get([key], [options])` -> `Object|any`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L179)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L179)
If no key is given, returns all values of the instance, also invoking virtual getters.
......@@ -118,7 +118,7 @@ If key is given and a field or virtual getter is present for the key it will cal
<a name="set"></a>
## `set(key, value, [options])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L249)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L249)
Set is used to update values on the instance (the sequelize representation of the instance that is, remember that nothing will be persisted before you actually call `save`).
In its most basic form `set` will update a value stored in the underlying `dataValues` object. However, if a custom setter function is defined for the key, that function
......@@ -156,7 +156,7 @@ __Aliases:__ setAttributes
<a name="changed"></a>
## `changed([key])` -> `Boolean|Array`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L401)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L401)
If changed is called with a string it will return a boolean indicating whether the value of that key in `dataValues` is different from the value in `_previousDataValues`.
......@@ -175,7 +175,7 @@ If changed is called without an argument and no keys have changed, it will retur
<a name="previous"></a>
## `previous([key])` -> `any|Array.<any>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L425)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L425)
Returns the previous value for key from `_previousDataValues`.
......@@ -192,7 +192,7 @@ If called without a key, returns the previous values for all values which have c
<a name="save"></a>
## `save([options])` -> `Promise.<this|Errors.ValidationError>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L493)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L493)
Validate this instance, and if the validation passes, persist it to the database. It will only save changed fields, and do nothing if no fields have changed.
......@@ -216,7 +216,7 @@ This error will have a property for each of the fields for which validation fail
<a name="reload"></a>
## `reload([options])` -> `Promise.<this>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L740)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L740)
Refresh the current instance in-place, i.e. update the object with current data from the DB and return the same object.
This is different from doing a `find(Instance.id)`, because that would create and return a new instance. With this method,
......@@ -239,7 +239,7 @@ all references to the Instance are updated with the new data and no new objects
<a name="validate"></a>
## `validate([options])` -> `Promise.<Errors.ValidationError|undefined>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L776)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L776)
Validate the attribute of this instance according to validation rules set in the model definition.
......@@ -262,7 +262,7 @@ Emits null if and only if validation successful; otherwise an Error instance con
<a name="update"></a>
## `update(updates, options)` -> `Promise.<this>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L796)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L796)
This is the same as calling `set` and then calling `save` but it only saves the
exact values passed to it, making it more atomic and safer.
......@@ -286,7 +286,7 @@ __Aliases:__ updateAttributes
<a name="destroy"></a>
## `destroy([options={}])` -> `Promise.<undefined>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L835)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L835)
Destroy the row corresponding to this instance. Depending on your setting for paranoid, the row will either be completely deleted, or have its deletedAt timestamp set to the current time.
......@@ -305,7 +305,7 @@ Destroy the row corresponding to this instance. Depending on your setting for pa
<a name="restore"></a>
## `restore([options={}])` -> `Promise.<undefined>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L882)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L882)
Restore the row corresponding to this instance. Only available for paranoid models.
......@@ -322,7 +322,7 @@ Restore the row corresponding to this instance. Only available for paranoid mode
<a name="increment"></a>
## `increment(fields, [options])` -> `Promise.<this>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L934)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L934)
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
......@@ -358,7 +358,7 @@ instance.increment({ answer: 42, tries: 1}, { by: 2 }) // increment answer by 42
<a name="decrement"></a>
## `decrement(fields, [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L997)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L997)
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
......@@ -394,7 +394,7 @@ instance.decrement({ answer: 42, tries: 1}, { by: 2 }) // decrement answer by 42
<a name="equals"></a>
## `equals(other)` -> `Boolean`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L1019)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L1019)
Check whether all values of this and `other` Instance are the same
......@@ -409,7 +409,7 @@ Check whether all values of this and `other` Instance are the same
<a name="equalsoneof"></a>
## `equalsOneOf(others)` -> `Boolean`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L1043)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L1043)
Check if this is equal to one of `others` by calling equals
......@@ -424,7 +424,7 @@ Check if this is equal to one of `others` by calling equals
<a name="tojson"></a>
## `toJSON()` -> `object`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/instance.js#L1061)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/instance.js#L1061)
Convert the instance to a JSON representation. Proxies to calling `get` with no keys. This means get all values gotten from the DB, and apply all custom getters.
......
<a name="model"></a>
# Class Model
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L26)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L26)
A Model represents a table in the database. Sometimes you might also see it referred to as model, or simply as factory.
This class should _not_ be instantiated directly, it is created using `sequelize.define`, and already created models can be loaded using `sequelize.import`
......@@ -12,7 +12,7 @@ This class should _not_ be instantiated directly, it is created using `sequelize
<a name="removeattribute"></a>
## `removeAttribute([attribute])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L966)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L964)
Remove attribute from model definition
......@@ -27,7 +27,7 @@ Remove attribute from model definition
<a name="sync"></a>
## `sync()` -> `Promise.<this>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L976)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L974)
Sync this Model to the DB, that is create the table. Upon success, the callback will be called with the model instance (this)
......@@ -40,7 +40,7 @@ Sync this Model to the DB, that is create the table. Upon success, the callback
<a name="drop"></a>
## `drop([options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1024)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1022)
Drop the table represented by this Model
......@@ -58,7 +58,7 @@ Drop the table represented by this Model
<a name="schema"></a>
## `schema(schema, [options])` -> `this`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1043)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1041)
Apply a schema to this model. For postgres, this will actually place the schema in front of the table name - `"schema"."tableName"`,
while the schema will be prepended to the table name for mysql and sqlite - `'schema.tablename'`.
......@@ -78,7 +78,7 @@ while the schema will be prepended to the table name for mysql and sqlite - `'sc
<a name="gettablename"></a>
## `getTableName([options])` -> `String|Object`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1077)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1075)
Get the tablename of the model, taking schema into account. The method will return The name as a string if the model has no schema,
or an object with `tableName`, `schema` and `delimiter` properties.
......@@ -96,7 +96,7 @@ or an object with `tableName`, `schema` and `delimiter` properties.
<a name="unscoped"></a>
## `unscoped()` -> `Model`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1084)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1082)
......@@ -104,7 +104,7 @@ or an object with `tableName`, `schema` and `delimiter` properties.
<a name="addscope"></a>
## `addScope(name, scope, [options])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1098)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1096)
Add a new scope to the model. This is especially useful for adding scopes with includes, when the model you want to include is not available at the time this model is defined.
......@@ -124,7 +124,7 @@ By default this will throw an error if a scope with that name already exists. Pa
<a name="scope"></a>
## `scope(options*)` -> `Model`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1162)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1160)
Apply a scope created in `define` to the model. First let's look at how to create scopes:
```js
......@@ -180,7 +180,7 @@ __Returns:__ A reference to the model, with the scope(s) applied. Calling scope
<a name="findall"></a>
## `findAll([options])` -> `Promise.<Array.<Instance>>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1329)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1327)
Search for multiple instances.
......@@ -291,7 +291,7 @@ __Aliases:__ all
<a name="findbyid"></a>
## `findById(id, [options])` -> `Promise.<Instance>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1458)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1456)
Search for a single instance by its primary key.
......@@ -315,7 +315,7 @@ __Aliases:__ findByPrimary
<a name="findone"></a>
## `findOne([options])` -> `Promise.<Instance>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1489)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1487)
Search for a single instance. This applies LIMIT 1, so the listener will always be called with a single instance.
......@@ -338,7 +338,7 @@ __Aliases:__ find
<a name="aggregate"></a>
## `aggregate(field, aggregateFunction, [options])` -> `Promise.<options.dataType|object>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1527)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1525)
Run an aggregation method on the specified field
......@@ -363,7 +363,7 @@ __Returns:__ Returns the aggregate result cast to `options.dataType`, unless `op
<a name="count"></a>
## `count([options])` -> `Promise.<Integer>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1581)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1579)
Count the number of records matching the provided where clause.
......@@ -389,7 +389,7 @@ If you provide an `include` option, the number of matching associations will be
<a name="findandcount"></a>
## `findAndCount([findOptions])` -> `Promise.<Object>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1640)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1638)
Find all the rows matching your query, within a specified offset / limit, and get the total number of rows matching your query. This is very useful for paging
......@@ -434,7 +434,7 @@ __Aliases:__ findAndCountAll
<a name="max"></a>
## `max(field, [options])` -> `Promise.<Any>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1704)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1702)
Find the maximum value of field
......@@ -455,7 +455,7 @@ Find the maximum value of field
<a name="min"></a>
## `min(field, [options])` -> `Promise.<Any>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1717)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1715)
Find the minimum value of field
......@@ -476,7 +476,7 @@ Find the minimum value of field
<a name="sum"></a>
## `sum(field, [options])` -> `Promise.<Number>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1730)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1728)
Find the sum of field
......@@ -497,7 +497,7 @@ Find the sum of field
<a name="build"></a>
## `build(values, [options])` -> `Instance`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1745)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1743)
Builds a new model instance. Values is an object of key value pairs, must be defined but can be empty.
......@@ -516,7 +516,7 @@ Builds a new model instance. Values is an object of key value pairs, must be def
<a name="create"></a>
## `create(values, [options])` -> `Promise.<Instance>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1817)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1815)
Builds a new model instance and calls save on it.
......@@ -547,7 +547,7 @@ Builds a new model instance and calls save on it.
<a name="findorinitialize"></a>
## `findOrInitialize` -> `Promise.<Instance, initialized>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1843)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1841)
Find a row that matches the query, or build (but don't save) the row if none is found.
The successful result of the promise will be (instance, initialized) - Make sure to use .spread()
......@@ -569,7 +569,7 @@ __Aliases:__ findOrBuild
<a name="findorcreate"></a>
## `findOrCreate(options)` -> `Promise.<Instance, created>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1885)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1883)
Find a row that matches the query, or build and save the row if none is found
The successful result of the promise will be (instance, created) - Make sure to use .spread()
......@@ -597,7 +597,7 @@ If a transaction is created, a savepoint will be created instead, and any unique
<a name="findcreatefind"></a>
## `findCreateFind(options)` -> `Promise.<Instance, created>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L1971)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L1969)
A more performant findOrCreate that will not work under a transaction (at least not in postgres)
Will execute a find call, if empty then attempt to create, if unique constraint then attempt to find again
......@@ -620,7 +620,7 @@ Will execute a find call, if empty then attempt to create, if unique constraint
<a name="upsert"></a>
## `upsert(values, [options])` -> `Promise.<created>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L2020)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L2018)
Insert or update a single row. An update will be executed if a row which matches the supplied values on either the primary key or a unique key is found. Note that the unique index must be defined in your sequelize model and not just in the table. Otherwise you may experience a unique constraint violation, because sequelize fails to identify the row that should be updated.
......@@ -652,7 +652,7 @@ __Aliases:__ insertOrUpdate
<a name="bulkcreate"></a>
## `bulkCreate(records, [options])` -> `Promise.<Array.<Instance>>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L2083)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L2081)
Create and insert multiple instances in bulk.
......@@ -683,7 +683,7 @@ To obtain Instances for the newly created values, you will need to query for the
<a name="truncate"></a>
## `truncate([options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L2236)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L2234)
Truncate all instances of the model. This is a convenient method for Model.destroy({ truncate: true }).
......@@ -709,7 +709,7 @@ Truncate all instances of the model. This is a convenient method for Model.destr
<a name="destroy"></a>
## `destroy(options)` -> `Promise.<Integer>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L2258)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L2256)
Delete multiple instances, or set their deletedAt timestamp to the current time if `paranoid` is enabled.
......@@ -735,7 +735,7 @@ __Returns:__ The number of destroyed rows
<a name="restore"></a>
## `restore(options)` -> `Promise.<undefined>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L2340)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L2338)
Restore multiple instances if `paranoid` is enabled.
......@@ -757,7 +757,7 @@ Restore multiple instances if `paranoid` is enabled.
<a name="update"></a>
## `update(values, options)` -> `Promise.<Array.<affectedCount, affectedRows>>`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L2419)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L2417)
Update multiple instances that match the where options. The promise returns an array with one or two elements. The first element is always the number
of affected rows, while the second element is the actual affected rows (only supported in postgres with `options.returning` true.)
......@@ -786,7 +786,7 @@ of affected rows, while the second element is the actual affected rows (only sup
<a name="describe"></a>
## `describe()` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/model.js#L2615)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/model.js#L2613)
Run a describe query on the table. The result will be return to the listener as a hash of attributes and their types.
......
<a name="sequelize"></a>
# Class Sequelize
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L31)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L31)
This is the main class, the entry point to sequelize. To use it, you just need to import sequelize:
......@@ -14,7 +14,7 @@ In addition to sequelize, the connection library for the dialect you want to use
<a name="sequelize"></a>
## `new Sequelize(database, [username=null], [password=null], [options={}])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L91)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L91)
Instantiate sequelize with name of database, username and password
......@@ -80,7 +80,7 @@ var sequelize = new Sequelize('mysql://localhost:3306/database', {})
<a name="sequelize"></a>
## `new Sequelize(uri, [options={}])`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L100)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L100)
Instantiate sequelize with an URI
......@@ -96,7 +96,7 @@ Instantiate sequelize with an URI
<a name="models"></a>
## `models`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L221)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L221)
Models are stored here under the name given to `sequelize.define`
......@@ -104,7 +104,7 @@ Models are stored here under the name given to `sequelize.define`
<a name="version"></a>
## `version`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L245)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L245)
Sequelize version number.
......@@ -112,7 +112,7 @@ Sequelize version number.
<a name="sequelize"></a>
## `Sequelize`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L254)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L254)
A reference to Sequelize constructor from sequelize. Useful for accessing DataTypes, Errors etc.
......@@ -125,7 +125,7 @@ A reference to Sequelize constructor from sequelize. Useful for accessing DataTy
<a name="utils"></a>
## `Utils`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L260)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L260)
A reference to sequelize utilities. Most users will not need to use these utils directly. However, you might want to use `Sequelize.Utils._`, which is a reference to the lodash library, if you don't already have it imported in your project.
......@@ -133,7 +133,7 @@ A reference to sequelize utilities. Most users will not need to use these utils
<a name="promise"></a>
## `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L266)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L266)
A handy reference to the bluebird Promise class
......@@ -141,7 +141,7 @@ A handy reference to the bluebird Promise class
<a name="querytypes"></a>
## `QueryTypes`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L272)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L272)
Available query types for use with `sequelize.query`
......@@ -149,7 +149,7 @@ Available query types for use with `sequelize.query`
<a name="validator"></a>
## `Validator`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L279)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L279)
Exposes the validator.js object, so you can extend it with custom validation functions. The validator is exposed both on the instance, and on the constructor.
......@@ -162,7 +162,7 @@ Exposes the validator.js object, so you can extend it with custom validation fun
<a name="transaction"></a>
## `Transaction`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L299)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L299)
A reference to the sequelize transaction class. Use this to access isolationLevels and types when creating a transaction
......@@ -176,7 +176,7 @@ A reference to the sequelize transaction class. Use this to access isolationLeve
<a name="deferrable"></a>
## `Deferrable`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L307)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L307)
A reference to the deferrable collection. Use this to access the different deferrable options.
......@@ -190,7 +190,7 @@ A reference to the deferrable collection. Use this to access the different defer
<a name="instance"></a>
## `Instance`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L314)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L314)
A reference to the sequelize instance class.
......@@ -203,7 +203,7 @@ A reference to the sequelize instance class.
<a name="association"></a>
## `Association`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L321)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L321)
A reference to the sequelize association class.
......@@ -216,7 +216,7 @@ A reference to the sequelize association class.
<a name="error"></a>
## `Error`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L334)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L334)
A general error class
......@@ -229,7 +229,7 @@ A general error class
<a name="validationerror"></a>
## `ValidationError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L342)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L342)
Emitted when a validation fails
......@@ -242,7 +242,7 @@ Emitted when a validation fails
<a name="validationerroritem"></a>
## `ValidationErrorItem`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L350)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L350)
Describes a validation error on an instance path
......@@ -255,7 +255,7 @@ Describes a validation error on an instance path
<a name="databaseerror"></a>
## `DatabaseError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L357)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L357)
A base class for all database related errors.
......@@ -268,7 +268,7 @@ A base class for all database related errors.
<a name="timeouterror"></a>
## `TimeoutError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L364)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L364)
Thrown when a database query times out because of a deadlock
......@@ -281,7 +281,7 @@ Thrown when a database query times out because of a deadlock
<a name="uniqueconstrainterror"></a>
## `UniqueConstraintError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L371)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L371)
Thrown when a unique constraint is violated in the database
......@@ -294,7 +294,7 @@ Thrown when a unique constraint is violated in the database
<a name="exclusionconstrainterror"></a>
## `ExclusionConstraintError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L378)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L378)
Thrown when an exclusion constraint is violated in the database
......@@ -307,7 +307,7 @@ Thrown when an exclusion constraint is violated in the database
<a name="foreignkeyconstrainterror"></a>
## `ForeignKeyConstraintError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L385)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L385)
Thrown when a foreign key constraint is violated in the database
......@@ -320,7 +320,7 @@ Thrown when a foreign key constraint is violated in the database
<a name="connectionerror"></a>
## `ConnectionError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L392)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L392)
A base class for all connection related errors.
......@@ -333,7 +333,7 @@ A base class for all connection related errors.
<a name="connectionrefusederror"></a>
## `ConnectionRefusedError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L399)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L399)
Thrown when a connection to a database is refused
......@@ -346,7 +346,7 @@ Thrown when a connection to a database is refused
<a name="accessdeniederror"></a>
## `AccessDeniedError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L406)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L406)
Thrown when a connection to a database is refused due to insufficient access
......@@ -359,7 +359,7 @@ Thrown when a connection to a database is refused due to insufficient access
<a name="hostnotfounderror"></a>
## `HostNotFoundError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L413)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L413)
Thrown when a connection to a database has a hostname that was not found
......@@ -372,7 +372,7 @@ Thrown when a connection to a database has a hostname that was not found
<a name="hostnotreachableerror"></a>
## `HostNotReachableError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L420)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L420)
Thrown when a connection to a database has a hostname that was not reachable
......@@ -385,7 +385,7 @@ Thrown when a connection to a database has a hostname that was not reachable
<a name="invalidconnectionerror"></a>
## `InvalidConnectionError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L427)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L427)
Thrown when a connection to a database has invalid values for any of the connection parameters
......@@ -398,7 +398,7 @@ Thrown when a connection to a database has invalid values for any of the connect
<a name="connectiontimedouterror"></a>
## `ConnectionTimedOutError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L434)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L434)
Thrown when a connection to a database times out
......@@ -411,7 +411,7 @@ Thrown when a connection to a database times out
<a name="instanceerror"></a>
## `InstanceError`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L441)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L441)
Thrown when a some problem occurred with Instance methods (see message for details)
......@@ -424,7 +424,7 @@ Thrown when a some problem occurred with Instance methods (see message for detai
<a name="getdialect"></a>
## `getDialect()` -> `String`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L454)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L454)
Returns the specified dialect.
__Returns:__ The specified dialect.
......@@ -433,7 +433,7 @@ __Returns:__ The specified dialect.
<a name="getqueryinterface"></a>
## `getQueryInterface()` -> `QueryInterface`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L466)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L466)
Returns an instance of QueryInterface.
......@@ -447,7 +447,7 @@ __Returns:__ An instance (singleton) of QueryInterface.
<a name="define"></a>
## `define(modelName, attributes, [options])` -> `Model`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L569)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L569)
Define a new model, representing a table in the DB.
......@@ -556,7 +556,7 @@ For more about validation, see http://docs.sequelizejs.com/en/latest/docs/models
<a name="model"></a>
## `model(modelName)` -> `Model`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L615)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L615)
Fetch a Model which is already defined
......@@ -571,7 +571,7 @@ Fetch a Model which is already defined
<a name="isdefined"></a>
## `isDefined(modelName)` -> `Boolean`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L629)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L629)
Checks whether a model with the given name is defined
......@@ -586,7 +586,7 @@ Checks whether a model with the given name is defined
<a name="import"></a>
## `import(path)` -> `Model`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L643)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L643)
Imports a model defined in another file
......@@ -605,7 +605,7 @@ See https://github.com/sequelize/express-example for a short example of how to d
<a name="query"></a>
## `query(sql, [options={}])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L708)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L708)
Execute a query on the DB, with the possibility to bypass all the sequelize goodness.
......@@ -658,7 +658,7 @@ sequelize.query('SELECT...', { type: sequelize.QueryTypes.SELECT }).then(functio
<a name="set"></a>
## `set(variables, options)` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L839)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L841)
Execute a query which would set an environment or user variable. The variables are set per connection, so this function needs a transaction.
Only works for MySQL.
......@@ -676,7 +676,7 @@ Only works for MySQL.
<a name="escape"></a>
## `escape(value)` -> `String`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L873)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L875)
Escape value.
......@@ -691,7 +691,7 @@ Escape value.
<a name="createschema"></a>
## `createSchema(schema, options={})` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L889)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L891)
Create a new database schema.
......@@ -716,7 +716,7 @@ not a database table. In mysql and sqlite, this command will do nothing.
<a name="showallschemas"></a>
## `showAllSchemas(options={})` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L902)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L904)
Show all defined schemas
......@@ -735,7 +735,7 @@ not a database table. In mysql and sqlite, this will show all tables.
<a name="dropschema"></a>
## `dropSchema(schema, options={})` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L916)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L918)
Drop a single schema
......@@ -755,7 +755,7 @@ not a database table. In mysql and sqlite, this drop a table matching the schema
<a name="dropallschemas"></a>
## `dropAllSchemas(options={})` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L929)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L931)
Drop all schemas
......@@ -774,7 +774,7 @@ not a database table. In mysql and sqlite, this is the equivalent of drop all ta
<a name="sync"></a>
## `sync([options={}])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L945)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L947)
Sync all defined models to the DB.
......@@ -795,7 +795,7 @@ Sync all defined models to the DB.
<a name="truncate"></a>
## `truncate([options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1001)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1003)
Truncate all tables defined through the sequelize models. This is done
by calling Model.truncate() on each model.
......@@ -818,7 +818,7 @@ by calling Model.truncate() on each model.
<a name="drop"></a>
## `drop(options)` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1023)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1025)
Drop all tables defined through this sequelize instance. This is done by calling Model.drop on each model
......@@ -839,7 +839,7 @@ Drop all tables defined through this sequelize instance. This is done by calling
<a name="authenticate"></a>
## `authenticate()` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1045)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1047)
Test the connection by trying to authenticate
__Aliases:__ validate
......@@ -848,7 +848,7 @@ __Aliases:__ validate
<a name="fn"></a>
## `fn(fn, args)` -> `Sequelize.fn`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1078)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1080)
Creates a object representing a database function. This can be used in search queries, both in where and order parts, and as default values in column definitions.
If you want to refer to columns in your function, you should use `sequelize.col`, so that the columns are properly interpreted as columns and not a strings.
......@@ -880,7 +880,7 @@ instance.updateAttributes({
<a name="col"></a>
## `col(col)` -> `Sequelize.col`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1091)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1093)
Creates a object representing a column in the DB. This is often useful in conjunction with `sequelize.fn`, since raw string arguments to fn will be escaped.
......@@ -900,7 +900,7 @@ Creates a object representing a column in the DB. This is often useful in conjun
<a name="cast"></a>
## `cast(val, type)` -> `Sequelize.cast`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1105)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1107)
Creates a object representing a call to the cast function.
......@@ -916,7 +916,7 @@ Creates a object representing a call to the cast function.
<a name="literal"></a>
## `literal(val)` -> `Sequelize.literal`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1118)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1120)
Creates a object representing a literal, i.e. something that will not be escaped.
......@@ -932,7 +932,7 @@ __Aliases:__ asIs
<a name="and"></a>
## `and(args)` -> `Sequelize.and`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1131)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1133)
An AND query
......@@ -952,7 +952,7 @@ An AND query
<a name="or"></a>
## `or(args)` -> `Sequelize.or`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1144)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1146)
An OR query
......@@ -972,7 +972,7 @@ An OR query
<a name="json"></a>
## `json(conditions, [value])` -> `Sequelize.json`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1157)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1159)
Creates an object representing nested where conditions for postgres's json data-type.
......@@ -993,7 +993,7 @@ Creates an object representing nested where conditions for postgres's json data-
<a name="where"></a>
## `where(attr, [comparator='='], logic)` -> `Sequelize.where`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1179)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1181)
A way of specifying attr = condition.
......@@ -1021,7 +1021,7 @@ __Aliases:__ condition
<a name="transaction"></a>
## `transaction([options={}])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/sequelize.js#L1233)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/sequelize.js#L1235)
Start a transaction. When using transactions, you should pass the transaction in the options argument in order for the query to happen under that transaction
......
<a name="transaction"></a>
# Class Transaction
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L20)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/transaction.js#L20)
The transaction object is used to identify a running transaction. It is created by calling `Sequelize.transaction()`.
......@@ -22,7 +22,7 @@ To run a query under a transaction, you should pass the transaction in the optio
<a name="types"></a>
## `TYPES`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L76)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/transaction.js#L76)
Types can be set per-transaction by passing `options.type` to `sequelize.transaction`.
Default to `DEFERRED` but you can override the default type by passing `options.transactionType` in `new Sequelize`.
......@@ -58,7 +58,7 @@ return sequelize.transaction({
<a name="isolation_levels"></a>
## `ISOLATION_LEVELS`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L116)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/transaction.js#L116)
Isolations levels can be set per-transaction by passing `options.isolationLevel` to `sequelize.transaction`.
Default to `REPEATABLE_READ` but you can override the default isolation level by passing `options.isolationLevel` in `new Sequelize`.
......@@ -94,7 +94,7 @@ return sequelize.transaction({
<a name="lock"></a>
## `LOCK`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L160)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/transaction.js#L160)
Possible options for row locking. Used in conjunction with `find` calls:
......@@ -134,7 +134,7 @@ UserModel will be locked but TaskModel won't!
<a name="commit"></a>
## `commit()` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L172)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/transaction.js#L172)
Commit the transaction
......@@ -142,7 +142,7 @@ Commit the transaction
<a name="rollback"></a>
## `rollback()` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L200)
[View code](https://github.com/sequelize/sequelize/blob/3e5b8772ef75169685fc96024366bca9958fee63/lib/transaction.js#L200)
Rollback (abort) the transaction
......
......@@ -126,6 +126,10 @@ Sequelize.RANGE(Sequelize.DATEONLY) // Defines daterange range. PostgreSQL onl
Sequelize.RANGE(Sequelize.DECIMAL) // Defines numrange range. PostgreSQL only.
Sequelize.ARRAY(Sequelize.RANGE(Sequelize.DATE)) // Defines array of tstzrange ranges. PostgreSQL only.
Sequelize.GEOMETRY // Spatial column. PostgreSQL (with PostGIS) or MySQL only.
Sequelize.GEOMETRY('POINT') // Spatial column with geomerty type. PostgreSQL (with PostGIS) or MySQL only.
Sequelize.GEOMETRY('POINT', 4326) // Spatial column with geomerty type and SRID. PostgreSQL (with PostGIS) or MySQL only.
```
The BLOB data type allows you to insert data both as strings and as buffers. When you do a find or findAll on a model which has a BLOB column. that data will always be returned as a buffer.
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!