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

Commit 5132e4d2 by Jan Aagaard Meier

[ci skip] Update docs, mostly type changes. Also a couple of new arguments to some functions

1 parent abe828bc
<a name="belongstomany"></a> <a name="belongstomany"></a>
# Mixin BelongsToMany # Mixin BelongsToMany
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L41) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L41)
Many-to-many association with a join table. 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 ...@@ -31,7 +31,7 @@ In the API reference below, replace `Assocation(s)` with the actual name of your
<a name="getassociations"></a> <a name="getassociations"></a>
## `getAssociations([options])` -> `Promise.<Array.<Instance>>` ## `getAssociations([options])` -> `Promise.<Array.<Instance>>`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L209) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L209)
Get everything currently associated with this, using an optional where clause. 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. ...@@ -49,7 +49,7 @@ Get everything currently associated with this, using an optional where clause.
<a name="setassociations"></a> <a name="setassociations"></a>
## `setAssociations([newAssociations], [options])` -> `Promise` ## `setAssociations([newAssociations], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L219) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/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. 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 ...@@ -66,7 +66,7 @@ Set the associated models by passing an array of instances or their primary keys
<a name="addassociations"></a> <a name="addassociations"></a>
## `addAssociations([newAssociations], [options])` -> `Promise` ## `addAssociations([newAssociations], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L229) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L229)
Associate several instances with this. Associate several instances with this.
...@@ -83,7 +83,7 @@ Associate several instances with this. ...@@ -83,7 +83,7 @@ Associate several instances with this.
<a name="addassociation"></a> <a name="addassociation"></a>
## `addAssociation([newAssociation], [options])` -> `Promise` ## `addAssociation([newAssociation], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L239) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L239)
Associate one instance with this. Associate one instance with this.
...@@ -100,7 +100,7 @@ Associate one instance with this. ...@@ -100,7 +100,7 @@ Associate one instance with this.
<a name="createassociation"></a> <a name="createassociation"></a>
## `createAssociation([values], [options])` -> `Promise` ## `createAssociation([values], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L248) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L248)
Create a new instance of the associated model and associate it with this. 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. ...@@ -116,7 +116,7 @@ Create a new instance of the associated model and associate it with this.
<a name="removeassociation"></a> <a name="removeassociation"></a>
## `removeAssociation([oldAssociated], [options])` -> `Promise` ## `removeAssociation([oldAssociated], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L257) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L257)
Un-associate the instance. Un-associate the instance.
...@@ -124,7 +124,7 @@ Un-associate the instance. ...@@ -124,7 +124,7 @@ Un-associate the instance.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [oldAssociated] | Instace &#124; String &#124; Number | Can be an Instance or its primary key | | [oldAssociated] | Instance &#124; String &#124; Number | Can be an Instance or its primary key |
| [options] | Object | Options passed to `through.destroy` | | [options] | Object | Options passed to `through.destroy` |
...@@ -132,7 +132,7 @@ Un-associate the instance. ...@@ -132,7 +132,7 @@ Un-associate the instance.
<a name="removeassociations"></a> <a name="removeassociations"></a>
## `removeAssociations([oldAssociated], [options])` -> `Promise` ## `removeAssociations([oldAssociated], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L266) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L266)
Un-associate several instances. Un-associate several instances.
...@@ -140,7 +140,7 @@ Un-associate several instances. ...@@ -140,7 +140,7 @@ Un-associate several instances.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [oldAssociated] | Array.&lt;Instace &#124; String &#124; Number&gt; | Can be an array of instances or their primary keys | | [oldAssociated] | Array.&lt;Instance &#124; String &#124; Number&gt; | Can be an array of instances or their primary keys |
| [options] | Object | Options passed to `through.destroy` | | [options] | Object | Options passed to `through.destroy` |
...@@ -148,7 +148,7 @@ Un-associate several instances. ...@@ -148,7 +148,7 @@ Un-associate several instances.
<a name="hasassociation"></a> <a name="hasassociation"></a>
## `hasAssociation([instance], [options])` -> `Promise` ## `hasAssociation([instance], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L275) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L275)
Check if an instance is associated with this. Check if an instance is associated with this.
...@@ -156,7 +156,7 @@ Check if an instance is associated with this. ...@@ -156,7 +156,7 @@ Check if an instance is associated with this.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [instance] | Instace &#124; String &#124; Number | Can be an Instance or its primary key | | [instance] | Instance &#124; String &#124; Number | Can be an Instance or its primary key |
| [options] | Object | Options passed to getAssociations | | [options] | Object | Options passed to getAssociations |
...@@ -164,7 +164,7 @@ Check if an instance is associated with this. ...@@ -164,7 +164,7 @@ Check if an instance is associated with this.
<a name="hasassociations"></a> <a name="hasassociations"></a>
## `hasAssociations([instances], [options])` -> `Promise` ## `hasAssociations([instances], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L284) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L284)
Check if all instances are associated with this. Check if all instances are associated with this.
...@@ -172,7 +172,7 @@ Check if all instances are associated with this. ...@@ -172,7 +172,7 @@ Check if all instances are associated with this.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [instances] | Array.&lt;Instace &#124; String &#124; Number&gt; | Can be an array of instances or their primary keys | | [instances] | Array.&lt;Instance &#124; String &#124; Number&gt; | Can be an array of instances or their primary keys |
| [options] | Object | Options passed to getAssociations | | [options] | Object | Options passed to getAssociations |
...@@ -180,7 +180,7 @@ Check if all instances are associated with this. ...@@ -180,7 +180,7 @@ Check if all instances are associated with this.
<a name="countassociations"></a> <a name="countassociations"></a>
## `countAssociations([options])` -> `Promise.<Int>` ## `countAssociations([options])` -> `Promise.<Int>`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to-many.js#L294) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to-many.js#L294)
Count everything currently associated with this, using an optional where clause. Count everything currently associated with this, using an optional where clause.
......
<a name="belongsto"></a> <a name="belongsto"></a>
# Mixin BelongsTo # Mixin BelongsTo
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to.js#L17) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to.js#L17)
One-to-one association One-to-one association
...@@ -10,7 +10,7 @@ In the API reference below, replace `Assocation` with the actual name of your as ...@@ -10,7 +10,7 @@ In the API reference below, replace `Assocation` with the actual name of your as
<a name="getassociation"></a> <a name="getassociation"></a>
## `getAssociation([options])` -> `Promise.<Instance>` ## `getAssociation([options])` -> `Promise.<Instance>`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to.js#L83) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to.js#L83)
Get the associated instance. Get the associated instance.
...@@ -27,7 +27,7 @@ Get the associated instance. ...@@ -27,7 +27,7 @@ Get the associated instance.
<a name="setassociation"></a> <a name="setassociation"></a>
## `setAssociation([newAssociation], [options])` -> `Promise` ## `setAssociation([newAssociation], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to.js#L93) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to.js#L93)
Set the associated model. Set the associated model.
...@@ -44,7 +44,7 @@ Set the associated model. ...@@ -44,7 +44,7 @@ Set the associated model.
<a name="createassociation"></a> <a name="createassociation"></a>
## `createAssociation([values], [options])` -> `Promise` ## `createAssociation([values], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/belongs-to.js#L102) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/belongs-to.js#L102)
Create a new instance of the associated model and associate it with this. Create a new instance of the associated model and associate it with this.
......
<a name="hasmany"></a> <a name="hasmany"></a>
# Mixin HasMany # Mixin HasMany
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L17) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L17)
One-to-many association One-to-many association
In the API reference below, replace `Assocation(s)` with the actual name of your association, e.g. for `User.hasMany(Project)` the getter will be `user.getProjects()`. In the API reference below, replace `Association(s)` with the actual name of your association, e.g. for `User.hasMany(Project)` the getter will be `user.getProjects()`.
*** ***
<a name="getassociations"></a> <a name="getassociations"></a>
## `getAssociations([options])` -> `Promise.<Array.<Instance>>` ## `getAssociations([options])` -> `Promise.<Array.<Instance>>`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L104) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L104)
Get everything currently associated with this, using an optional where clause. Get everything currently associated with this, using an optional where clause.
...@@ -28,9 +28,9 @@ Get everything currently associated with this, using an optional where clause. ...@@ -28,9 +28,9 @@ Get everything currently associated with this, using an optional where clause.
<a name="setassociations"></a> <a name="setassociations"></a>
## `setAssociations([newAssociations], [options])` -> `Promise` ## `setAssociations([newAssociations], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L114) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L114)
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 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
**Params:** **Params:**
...@@ -45,7 +45,7 @@ Set the associated models by passing an array of instances or their primary keys ...@@ -45,7 +45,7 @@ Set the associated models by passing an array of instances or their primary keys
<a name="addassociations"></a> <a name="addassociations"></a>
## `addAssociations([newAssociations], [options])` -> `Promise` ## `addAssociations([newAssociations], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L124) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L124)
Associate several instances with this. Associate several instances with this.
...@@ -62,7 +62,7 @@ Associate several instances with this. ...@@ -62,7 +62,7 @@ Associate several instances with this.
<a name="addassociation"></a> <a name="addassociation"></a>
## `addAssociation([newAssociation], [options])` -> `Promise` ## `addAssociation([newAssociation], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L134) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L134)
Associate one instance with this. Associate one instance with this.
...@@ -79,7 +79,7 @@ Associate one instance with this. ...@@ -79,7 +79,7 @@ Associate one instance with this.
<a name="createassociation"></a> <a name="createassociation"></a>
## `createAssociation([values], [options])` -> `Promise` ## `createAssociation([values], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L143) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L143)
Create a new instance of the associated model and associate it with this. 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. ...@@ -95,7 +95,7 @@ Create a new instance of the associated model and associate it with this.
<a name="removeassociation"></a> <a name="removeassociation"></a>
## `removeAssociation([oldAssociated], [options])` -> `Promise` ## `removeAssociation([oldAssociated], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L152) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L152)
Un-associate the instance. Un-associate the instance.
...@@ -103,7 +103,7 @@ Un-associate the instance. ...@@ -103,7 +103,7 @@ Un-associate the instance.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [oldAssociated] | Instace &#124; String &#124; Number | Can be an Instance or its primary key | | [oldAssociated] | Instance &#124; String &#124; Number | Can be an Instance or its primary key |
| [options] | Object | Options passed to `target.update` | | [options] | Object | Options passed to `target.update` |
...@@ -111,7 +111,7 @@ Un-associate the instance. ...@@ -111,7 +111,7 @@ Un-associate the instance.
<a name="removeassociations"></a> <a name="removeassociations"></a>
## `removeAssociations([oldAssociatedArray], [options])` -> `Promise` ## `removeAssociations([oldAssociatedArray], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L161) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L161)
Un-associate several instances. Un-associate several instances.
...@@ -119,7 +119,7 @@ Un-associate several instances. ...@@ -119,7 +119,7 @@ Un-associate several instances.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [oldAssociatedArray] | Array.&lt;Instace &#124; String &#124; Number&gt; | Can be an array of instances or their primary keys | | [oldAssociatedArray] | Array.&lt;Instance &#124; String &#124; Number&gt; | Can be an array of instances or their primary keys |
| [options] | Object | Options passed to `through.destroy` | | [options] | Object | Options passed to `through.destroy` |
...@@ -127,7 +127,7 @@ Un-associate several instances. ...@@ -127,7 +127,7 @@ Un-associate several instances.
<a name="hasassociation"></a> <a name="hasassociation"></a>
## `hasAssociation([instance], [options])` -> `Promise` ## `hasAssociation([instance], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L170) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L170)
Check if an instance is associated with this. Check if an instance is associated with this.
...@@ -135,7 +135,7 @@ Check if an instance is associated with this. ...@@ -135,7 +135,7 @@ Check if an instance is associated with this.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [instance] | Instace &#124; String &#124; Number | Can be an Instance or its primary key | | [instance] | Instance &#124; String &#124; Number | Can be an Instance or its primary key |
| [options] | Object | Options passed to getAssociations | | [options] | Object | Options passed to getAssociations |
...@@ -143,7 +143,7 @@ Check if an instance is associated with this. ...@@ -143,7 +143,7 @@ Check if an instance is associated with this.
<a name="hasassociations"></a> <a name="hasassociations"></a>
## `hasAssociations([instances], [options])` -> `Promise` ## `hasAssociations([instances], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L179) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L179)
Check if all instances are associated with this. Check if all instances are associated with this.
...@@ -151,7 +151,7 @@ Check if all instances are associated with this. ...@@ -151,7 +151,7 @@ Check if all instances are associated with this.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [instances] | Array.&lt;Instace &#124; String &#124; Number&gt; | Can be an array of instances or their primary keys | | [instances] | Array.&lt;Instance &#124; String &#124; Number&gt; | Can be an array of instances or their primary keys |
| [options] | Object | Options passed to getAssociations | | [options] | Object | Options passed to getAssociations |
...@@ -159,7 +159,7 @@ Check if all instances are associated with this. ...@@ -159,7 +159,7 @@ Check if all instances are associated with this.
<a name="countassociations"></a> <a name="countassociations"></a>
## `countAssociations([options])` -> `Promise.<Int>` ## `countAssociations([options])` -> `Promise.<Int>`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-many.js#L189) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-many.js#L189)
Count everything currently associated with this, using an optional where clause. Count everything currently associated with this, using an optional where clause.
......
<a name="hasone"></a> <a name="hasone"></a>
# Mixin HasOne # Mixin HasOne
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-one.js#L17) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-one.js#L17)
One-to-one association One-to-one association
In the API reference below, replace `Assocation` with the actual name of your association, e.g. for `User.hasOne(Project)` the getter will be `user.getProject()`. In the API reference below, replace `Association` with the actual name of your association, e.g. for `User.hasOne(Project)` the getter will be `user.getProject()`.
This is almost the same as `belongsTo` with one exception. The foreign key will be defined on the target model. This is almost the same as `belongsTo` with one exception. The foreign key will be defined on the target model.
*** ***
<a name="getassociation"></a> <a name="getassociation"></a>
## `getAssociation([options])` -> `Promise.<Instance>` ## `getAssociation([options])` -> `Promise.<Instance>`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-one.js#L77) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-one.js#L78)
Get the associated instance. Get the associated instance.
...@@ -28,7 +28,7 @@ Get the associated instance. ...@@ -28,7 +28,7 @@ Get the associated instance.
<a name="setassociation"></a> <a name="setassociation"></a>
## `setAssociation([newAssociation], [options])` -> `Promise` ## `setAssociation([newAssociation], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-one.js#L86) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-one.js#L87)
Set the associated model. Set the associated model.
...@@ -37,14 +37,14 @@ Set the associated model. ...@@ -37,14 +37,14 @@ Set the associated model.
| Name | Type | Description | | Name | Type | Description |
| ---- | ---- | ----------- | | ---- | ---- | ----------- |
| [newAssociation] | Instance &#124; String &#124; Number | An instance or the primary key of an instance to associate with this. Pass `null` or `undefined` to remove the association. | | [newAssociation] | Instance &#124; String &#124; Number | An instance or the primary key of an instance to associate with this. Pass `null` or `undefined` to remove the association. |
| [options] | Object | Options passed to getAssocation and `target.save` | | [options] | Object | Options passed to getAssociation and `target.save` |
*** ***
<a name="createassociation"></a> <a name="createassociation"></a>
## `createAssociation([values], [options])` -> `Promise` ## `createAssociation([values], [options])` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/associations/has-one.js#L95) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/associations/has-one.js#L96)
Create a new instance of the associated model and associate it with this. Create a new instance of the associated model and associate it with this.
......
<a name="deferrable"></a> <a name="deferrable"></a>
## `Deferrable()` -> `object` ## `Deferrable()` -> `object`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/deferrable.js#L39) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L39)
A collection of properties related to deferrable constraints. It can be used to A collection of properties related to deferrable constraints. It can be used to
make foreign key constraints deferrable and to set the constaints within a make foreign key constraints deferrable and to set the constraints within a
transaction. This is only supported in PostgreSQL. transaction. This is only supported in PostgreSQL.
The foreign keys can be configured like this. It will create a foreign key The foreign keys can be configured like this. It will create a foreign key
...@@ -36,7 +36,7 @@ sequelize.transaction({ ...@@ -36,7 +36,7 @@ sequelize.transaction({
<a name="initially_deferred"></a> <a name="initially_deferred"></a>
## `INITIALLY_DEFERRED()` ## `INITIALLY_DEFERRED()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/deferrable.js#L59) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L59)
A property that will defer constraints checks to the end of transactions. 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. ...@@ -44,7 +44,7 @@ A property that will defer constraints checks to the end of transactions.
<a name="initially_immediate"></a> <a name="initially_immediate"></a>
## `INITIALLY_IMMEDIATE()` ## `INITIALLY_IMMEDIATE()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/deferrable.js#L76) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L76)
A property that will trigger the constraint checks immediately A property that will trigger the constraint checks immediately
...@@ -52,7 +52,7 @@ 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> <a name="not"></a>
## `NOT()` ## `NOT()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/deferrable.js#L95) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L95)
A property that will set the constraints to not deferred. This is A property that will set the constraints to not deferred. This is
the default in PostgreSQL and it make it impossible to dynamically the default in PostgreSQL and it make it impossible to dynamically
...@@ -62,7 +62,7 @@ defer the constraints within a transaction. ...@@ -62,7 +62,7 @@ defer the constraints within a transaction.
<a name="set_deferred"></a> <a name="set_deferred"></a>
## `SET_DEFERRED(constraints)` ## `SET_DEFERRED(constraints)`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/deferrable.js#L114) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L114)
A property that will trigger an additional query at the beginning of a A property that will trigger an additional query at the beginning of a
transaction which sets the constraints to deferred. transaction which sets the constraints to deferred.
...@@ -78,7 +78,7 @@ transaction which sets the constraints to deferred. ...@@ -78,7 +78,7 @@ transaction which sets the constraints to deferred.
<a name="set_immediate"></a> <a name="set_immediate"></a>
## `SET_IMMEDIATE(constraints)` ## `SET_IMMEDIATE(constraints)`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/deferrable.js#L135) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/deferrable.js#L135)
A property that will trigger an additional query at the beginning of a A property that will trigger an additional query at the beginning of a
transaction which sets the constraints to immediately. transaction which sets the constraints to immediately.
......
<a name="errors"></a> <a name="errors"></a>
# Class Errors # Class Errors
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L11) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/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. 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. All sequelize errors inherit from the base JS error object.
...@@ -9,7 +9,7 @@ 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> <a name="baseerror"></a>
## `new BaseError()` ## `new BaseError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L20) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L20)
The Base Error all Sequelize Errors inherit from. The Base Error all Sequelize Errors inherit from.
__Aliases:__ Error __Aliases:__ Error
...@@ -18,7 +18,7 @@ __Aliases:__ Error ...@@ -18,7 +18,7 @@ __Aliases:__ Error
<a name="validationerror"></a> <a name="validationerror"></a>
## `new ValidationError(message, [errors])` ## `new ValidationError(message, [errors])`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L41) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L41)
Validation Error. Thrown when the sequelize validation has failed. The error contains an `errors` property, 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. which is an array with 1 or more ValidationErrorItems, one for each validation that failed.
...@@ -37,7 +37,7 @@ __Extends:__ BaseError ...@@ -37,7 +37,7 @@ __Extends:__ BaseError
<a name="errors"></a> <a name="errors"></a>
## `errors` ## `errors`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L49) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L49)
An array of ValidationErrorItems An array of ValidationErrorItems
...@@ -45,7 +45,7 @@ An array of ValidationErrorItems ...@@ -45,7 +45,7 @@ An array of ValidationErrorItems
<a name="get"></a> <a name="get"></a>
## `get(path)` ## `get(path)`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L70) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L70)
Gets all validation error items for the path / field specified. Gets all validation error items for the path / field specified.
...@@ -60,7 +60,7 @@ 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> <a name="databaseerror"></a>
## `new DatabaseError()` ## `new DatabaseError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L84) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L84)
A base class for all database related errors. A base class for all database related errors.
...@@ -70,7 +70,7 @@ __Extends:__ BaseError ...@@ -70,7 +70,7 @@ __Extends:__ BaseError
<a name="parent"></a> <a name="parent"></a>
## `parent` ## `parent`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L92) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L92)
The database specific error which triggered this one The database specific error which triggered this one
...@@ -78,7 +78,7 @@ The database specific error which triggered this one ...@@ -78,7 +78,7 @@ The database specific error which triggered this one
<a name="sql"></a> <a name="sql"></a>
## `sql` ## `sql`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L98) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L98)
The SQL that triggered the error The SQL that triggered the error
...@@ -86,7 +86,7 @@ The SQL that triggered the error ...@@ -86,7 +86,7 @@ The SQL that triggered the error
<a name="message"></a> <a name="message"></a>
## `message()` ## `message()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L104) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L104)
The message from the DB. The message from the DB.
...@@ -94,7 +94,7 @@ The message from the DB. ...@@ -94,7 +94,7 @@ The message from the DB.
<a name="fields"></a> <a name="fields"></a>
## `fields()` ## `fields()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L109) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L109)
The fields of the unique constraint The fields of the unique constraint
...@@ -102,7 +102,7 @@ The fields of the unique constraint ...@@ -102,7 +102,7 @@ The fields of the unique constraint
<a name="value"></a> <a name="value"></a>
## `value()` ## `value()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L114) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L114)
The value(s) which triggered the error The value(s) which triggered the error
...@@ -110,7 +110,7 @@ The value(s) which triggered the error ...@@ -110,7 +110,7 @@ The value(s) which triggered the error
<a name="index"></a> <a name="index"></a>
## `index()` ## `index()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L119) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L119)
The name of the index that triggered the error The name of the index that triggered the error
...@@ -118,7 +118,7 @@ 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> <a name="timeouterror"></a>
## `new TimeoutError()` ## `new TimeoutError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L127) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L127)
Thrown when a database query times out because of a deadlock Thrown when a database query times out because of a deadlock
...@@ -128,7 +128,7 @@ __Extends:__ DatabaseError ...@@ -128,7 +128,7 @@ __Extends:__ DatabaseError
<a name="uniqueconstrainterror"></a> <a name="uniqueconstrainterror"></a>
## `new UniqueConstraintError()` ## `new UniqueConstraintError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L138) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L138)
Thrown when a unique constraint is violated in the database Thrown when a unique constraint is violated in the database
...@@ -138,7 +138,7 @@ __Extends:__ DatabaseError ...@@ -138,7 +138,7 @@ __Extends:__ DatabaseError
<a name="foreignkeyconstrainterror"></a> <a name="foreignkeyconstrainterror"></a>
## `new ForeignKeyConstraintError()` ## `new ForeignKeyConstraintError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L157) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L157)
Thrown when a foreign key constraint is violated in the database Thrown when a foreign key constraint is violated in the database
...@@ -148,7 +148,7 @@ __Extends:__ DatabaseError ...@@ -148,7 +148,7 @@ __Extends:__ DatabaseError
<a name="exclusionconstrainterror"></a> <a name="exclusionconstrainterror"></a>
## `new ExclusionConstraintError()` ## `new ExclusionConstraintError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L177) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L177)
Thrown when an exclusion constraint is violated in the database Thrown when an exclusion constraint is violated in the database
...@@ -158,7 +158,7 @@ __Extends:__ DatabaseError ...@@ -158,7 +158,7 @@ __Extends:__ DatabaseError
<a name="validationerroritem"></a> <a name="validationerroritem"></a>
## `new ValidationErrorItem(message, type, path, value)` ## `new ValidationErrorItem(message, type, path, value)`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L201) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L201)
Validation Error Item Validation Error Item
Instances of this class are included in the `ValidationError.errors` property. 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. ...@@ -177,7 +177,7 @@ Instances of this class are included in the `ValidationError.errors` property.
<a name="connectionerror"></a> <a name="connectionerror"></a>
## `new ConnectionError()` ## `new ConnectionError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L213) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L213)
A base class for all connection related errors. A base class for all connection related errors.
...@@ -187,7 +187,7 @@ __Extends:__ BaseError ...@@ -187,7 +187,7 @@ __Extends:__ BaseError
<a name="parent"></a> <a name="parent"></a>
## `parent` ## `parent`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L220) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L220)
The connection specific error which triggered this one The connection specific error which triggered this one
...@@ -195,7 +195,7 @@ The connection specific error which triggered this one ...@@ -195,7 +195,7 @@ The connection specific error which triggered this one
<a name="connectionrefusederror"></a> <a name="connectionrefusederror"></a>
## `new ConnectionRefusedError()` ## `new ConnectionRefusedError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L230) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L230)
Thrown when a connection to a database is refused Thrown when a connection to a database is refused
...@@ -205,7 +205,7 @@ __Extends:__ ConnectionError ...@@ -205,7 +205,7 @@ __Extends:__ ConnectionError
<a name="accessdeniederror"></a> <a name="accessdeniederror"></a>
## `new AccessDeniedError()` ## `new AccessDeniedError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L241) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L241)
Thrown when a connection to a database is refused due to insufficient privileges Thrown when a connection to a database is refused due to insufficient privileges
...@@ -215,7 +215,7 @@ __Extends:__ ConnectionError ...@@ -215,7 +215,7 @@ __Extends:__ ConnectionError
<a name="hostnotfounderror"></a> <a name="hostnotfounderror"></a>
## `new HostNotFoundError()` ## `new HostNotFoundError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L252) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L252)
Thrown when a connection to a database has a hostname that was not found Thrown when a connection to a database has a hostname that was not found
...@@ -225,7 +225,7 @@ __Extends:__ ConnectionError ...@@ -225,7 +225,7 @@ __Extends:__ ConnectionError
<a name="hostnotreachableerror"></a> <a name="hostnotreachableerror"></a>
## `new HostNotReachableError()` ## `new HostNotReachableError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L263) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L263)
Thrown when a connection to a database has a hostname that was not reachable Thrown when a connection to a database has a hostname that was not reachable
...@@ -235,7 +235,7 @@ __Extends:__ ConnectionError ...@@ -235,7 +235,7 @@ __Extends:__ ConnectionError
<a name="invalidconnectionerror"></a> <a name="invalidconnectionerror"></a>
## `new InvalidConnectionError()` ## `new InvalidConnectionError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L274) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L274)
Thrown when a connection to a database has invalid values for any of the connection parameters Thrown when a connection to a database has invalid values for any of the connection parameters
...@@ -245,7 +245,7 @@ __Extends:__ ConnectionError ...@@ -245,7 +245,7 @@ __Extends:__ ConnectionError
<a name="connectiontimedouterror"></a> <a name="connectiontimedouterror"></a>
## `new ConnectionTimedOutError()` ## `new ConnectionTimedOutError()`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/errors.js#L285) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L285)
Thrown when a connection to a database times out Thrown when a connection to a database times out
...@@ -253,4 +253,14 @@ __Extends:__ ConnectionError ...@@ -253,4 +253,14 @@ __Extends:__ ConnectionError
*** ***
<a name="instanceerror"></a>
## `new InstanceError()`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/errors.js#L296)
Thrown when a some problem occurred with Instance methods (see message for details)
__Extends:__ BaseError
***
_This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on <a href="irc://irc.freenode.net/#sequelizejs">IRC</a>, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org) and [dox](https://github.com/tj/dox)_ _This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on <a href="irc://irc.freenode.net/#sequelizejs">IRC</a>, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org) and [dox](https://github.com/tj/dox)_
\ No newline at end of file
<a name="transaction"></a> <a name="transaction"></a>
# Class Transaction # Class Transaction
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/transaction.js#L19) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L20)
The transaction object is used to identify a running transaction. It is created by calling `Sequelize.transaction()`. The transaction object is used to identify a running transaction. It is created by calling `Sequelize.transaction()`.
...@@ -13,15 +13,52 @@ To run a query under a transaction, you should pass the transaction in the optio ...@@ -13,15 +13,52 @@ To run a query under a transaction, you should pass the transaction in the optio
| sequelize | Sequelize | A configured sequelize Instance | | sequelize | Sequelize | A configured sequelize Instance |
| options | Object | An object with options | | options | Object | An object with options |
| options.autocommit=true | Boolean | Sets the autocommit property of the transaction. | | options.autocommit=true | Boolean | Sets the autocommit property of the transaction. |
| options.type=true | String | Sets the type of the transaction. |
| options.isolationLevel=true | String | Sets the isolation level of the transaction. | | options.isolationLevel=true | String | Sets the isolation level of the transaction. |
| options.deferrable | String | Sets the constraints to be deferred or immediately checked. | | options.deferrable | String | Sets the constraints to be deferred or immediately checked. |
*** ***
<a name="types"></a>
## `TYPES`
[View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/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`.
Sqlite only.
The possible types to use when starting a transaction:
```js
{
DEFERRED: "DEFERRED",
IMMEDIATE: "IMMEDIATE",
EXCLUSIVE: "EXCLUSIVE"
}
```
Pass in the desired level as the first argument:
```js
return sequelize.transaction({
type: Sequelize.Transaction.EXCLUSIVE
}, function (t) {
// your transactions
}).then(function(result) {
// transaction has been committed. Do something after the commit if required.
}).catch(function(err) {
// do something with the err.
});
```
***
<a name="isolation_levels"></a> <a name="isolation_levels"></a>
## `ISOLATION_LEVELS` ## `ISOLATION_LEVELS`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/transaction.js#L71) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L116)
Isolations levels can be set per-transaction by passing `options.isolationLevel` to `sequelize.transaction`. 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`. Default to `REPEATABLE_READ` but you can override the default isolation level by passing `options.isolationLevel` in `new Sequelize`.
...@@ -57,9 +94,9 @@ return sequelize.transaction({ ...@@ -57,9 +94,9 @@ return sequelize.transaction({
<a name="lock"></a> <a name="lock"></a>
## `LOCK` ## `LOCK`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/transaction.js#L115) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L160)
Possible options for row locking. Used in conjuction with `find` calls: Possible options for row locking. Used in conjunction with `find` calls:
```js ```js
t1 // is a transaction t1 // is a transaction
...@@ -97,7 +134,7 @@ UserModel will be locked but TaskModel won't! ...@@ -97,7 +134,7 @@ UserModel will be locked but TaskModel won't!
<a name="commit"></a> <a name="commit"></a>
## `commit()` -> `Promise` ## `commit()` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/transaction.js#L127) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L172)
Commit the transaction Commit the transaction
...@@ -105,7 +142,7 @@ Commit the transaction ...@@ -105,7 +142,7 @@ Commit the transaction
<a name="rollback"></a> <a name="rollback"></a>
## `rollback()` -> `Promise` ## `rollback()` -> `Promise`
[View code](https://github.com/sequelize/sequelize/blob/0de404640d4c71e2d1f1259356650dfb586a248b/lib/transaction.js#L154) [View code](https://github.com/sequelize/sequelize/blob/d10eee53d37abb67db47160f067ac3cdc7e1bf43/lib/transaction.js#L200)
Rollback (abort) the transaction Rollback (abort) the transaction
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!