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

Commit 837c0517 by Jan Aagaard Meier

[ci skip] Fix code formatting in api docs for data types

1 parent 80e81972
Showing with 30 additions and 28 deletions
<a name="datatypes"></a> <a name="datatypes"></a>
# Class DataTypes # Class DataTypes
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L41) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L41)
A convenience class holding commonly used data types. The datatypes are used when defining a new model using `Sequelize.define`, like this: A convenience class holding commonly used data types. The datatypes are used when defining a new model using `Sequelize.define`, like this:
```js ```js
sequelize.define('model', { sequelize.define('model', {
...@@ -33,7 +33,7 @@ sequelize.define('model', { ...@@ -33,7 +33,7 @@ sequelize.define('model', {
<a name="string"></a> <a name="string"></a>
## `STRING()` ## `STRING()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L67) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L67)
A variable length string. Default length 255 A variable length string. Default length 255
Available properties: `BINARY` Available properties: `BINARY`
...@@ -43,7 +43,7 @@ Available properties: `BINARY` ...@@ -43,7 +43,7 @@ Available properties: `BINARY`
<a name="char"></a> <a name="char"></a>
## `CHAR()` ## `CHAR()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L112) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L112)
A fixed length string. Default length 255 A fixed length string. Default length 255
Available properties: `BINARY` Available properties: `BINARY`
...@@ -53,14 +53,14 @@ Available properties: `BINARY` ...@@ -53,14 +53,14 @@ Available properties: `BINARY`
<a name="text"></a> <a name="text"></a>
## `TEXT()` ## `TEXT()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L132) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L132)
An (un)limited length text column. Available lengths: `tiny`, `medium`, `long` An (un)limited length text column. Available lengths: `tiny`, `medium`, `long`
*** ***
<a name="integer"></a> <a name="integer"></a>
## `INTEGER()` ## `INTEGER()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L221) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L221)
A 32 bit integer. A 32 bit integer.
Available properties: `UNSIGNED`, `ZEROFILL` Available properties: `UNSIGNED`, `ZEROFILL`
...@@ -70,7 +70,7 @@ Available properties: `UNSIGNED`, `ZEROFILL` ...@@ -70,7 +70,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="bigint"></a> <a name="bigint"></a>
## `BIGINT()` ## `BIGINT()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L247) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L247)
A 64 bit integer. A 64 bit integer.
Available properties: `UNSIGNED`, `ZEROFILL` Available properties: `UNSIGNED`, `ZEROFILL`
...@@ -80,7 +80,7 @@ Available properties: `UNSIGNED`, `ZEROFILL` ...@@ -80,7 +80,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="float"></a> <a name="float"></a>
## `FLOAT()` ## `FLOAT()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L272) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L272)
Floating point number (4-byte precision). Accepts one or two arguments for precision Floating point number (4-byte precision). Accepts one or two arguments for precision
Available properties: `UNSIGNED`, `ZEROFILL` Available properties: `UNSIGNED`, `ZEROFILL`
...@@ -90,7 +90,7 @@ Available properties: `UNSIGNED`, `ZEROFILL` ...@@ -90,7 +90,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="real"></a> <a name="real"></a>
## `REAL()` ## `REAL()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L298) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L298)
Floating point number (4-byte precision). Accepts one or two arguments for precision Floating point number (4-byte precision). Accepts one or two arguments for precision
Available properties: `UNSIGNED`, `ZEROFILL` Available properties: `UNSIGNED`, `ZEROFILL`
...@@ -100,7 +100,7 @@ Available properties: `UNSIGNED`, `ZEROFILL` ...@@ -100,7 +100,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="double"></a> <a name="double"></a>
## `DOUBLE()` ## `DOUBLE()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L317) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L317)
Floating point number (8-byte precision). Accepts one or two arguments for precision Floating point number (8-byte precision). Accepts one or two arguments for precision
Available properties: `UNSIGNED`, `ZEROFILL` Available properties: `UNSIGNED`, `ZEROFILL`
...@@ -110,7 +110,7 @@ Available properties: `UNSIGNED`, `ZEROFILL` ...@@ -110,7 +110,7 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="decimal"></a> <a name="decimal"></a>
## `DECIMAL()` ## `DECIMAL()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L336) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L336)
Decimal number. Accepts one or two arguments for precision Decimal number. Accepts one or two arguments for precision
Available properties: `UNSIGNED`, `ZEROFILL` Available properties: `UNSIGNED`, `ZEROFILL`
...@@ -120,63 +120,63 @@ Available properties: `UNSIGNED`, `ZEROFILL` ...@@ -120,63 +120,63 @@ Available properties: `UNSIGNED`, `ZEROFILL`
<a name="boolean"></a> <a name="boolean"></a>
## `BOOLEAN()` ## `BOOLEAN()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L366) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L366)
A boolean / tinyint column, depending on dialect A boolean / tinyint column, depending on dialect
*** ***
<a name="time"></a> <a name="time"></a>
## `TIME()` ## `TIME()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L389) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L389)
A time column A time column
*** ***
<a name="date"></a> <a name="date"></a>
## `DATE()` ## `DATE()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L404) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L404)
A datetime column A datetime column
*** ***
<a name="dateonly"></a> <a name="dateonly"></a>
## `DATEONLY()` ## `DATEONLY()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L426) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L426)
A date only column A date only column
*** ***
<a name="hstore"></a> <a name="hstore"></a>
## `HSTORE()` ## `HSTORE()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L442) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L442)
A key / value column. Only available in postgres. A key / value column. Only available in postgres.
*** ***
<a name="json"></a> <a name="json"></a>
## `JSON()` ## `JSON()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L461) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L461)
A JSON string column. Only available in postgres. A JSON string column. Only available in postgres.
*** ***
<a name="jsonb"></a> <a name="jsonb"></a>
## `JSONB()` ## `JSONB()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L476) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L476)
A pre-processed JSON data column. Only available in postgres. A pre-processed JSON data column. Only available in postgres.
*** ***
<a name="now"></a> <a name="now"></a>
## `NOW()` ## `NOW()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L488) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L488)
A default value of the current timestamp A default value of the current timestamp
*** ***
<a name="blob"></a> <a name="blob"></a>
## `BLOB()` ## `BLOB()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L502) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L502)
Binary storage. Available lengths: `tiny`, `medium`, `long` Binary storage. Available lengths: `tiny`, `medium`, `long`
...@@ -184,7 +184,7 @@ Binary storage. Available lengths: `tiny`, `medium`, `long` ...@@ -184,7 +184,7 @@ Binary storage. Available lengths: `tiny`, `medium`, `long`
<a name="range"></a> <a name="range"></a>
## `RANGE()` ## `RANGE()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L539) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L539)
Range types are data types representing a range of values of some element type (called the range's subtype). Range types are data types representing a range of values of some element type (called the range's subtype).
Only available in postgres. Only available in postgres.
See {@link http://www.postgresql.org/docs/9.4/static/rangetypes.html|Postgres documentation} for more details See {@link http://www.postgresql.org/docs/9.4/static/rangetypes.html|Postgres documentation} for more details
...@@ -193,28 +193,28 @@ See {@link http://www.postgresql.org/docs/9.4/static/rangetypes.html|Postgres do ...@@ -193,28 +193,28 @@ See {@link http://www.postgresql.org/docs/9.4/static/rangetypes.html|Postgres do
<a name="uuid"></a> <a name="uuid"></a>
## `UUID()` ## `UUID()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L583) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L583)
A column storing a unique univeral identifier. Use with `UUIDV1` or `UUIDV4` for default values. A column storing a unique univeral identifier. Use with `UUIDV1` or `UUIDV4` for default values.
*** ***
<a name="uuidv1"></a> <a name="uuidv1"></a>
## `UUIDV1()` ## `UUIDV1()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L603) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L603)
A default unique universal identifier generated following the UUID v1 standard A default unique universal identifier generated following the UUID v1 standard
*** ***
<a name="uuidv4"></a> <a name="uuidv4"></a>
## `UUIDV4()` ## `UUIDV4()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L623) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L623)
A default unique universal identifier generated following the UUID v2 standard A default unique universal identifier generated following the UUID v2 standard
*** ***
<a name="virtual"></a> <a name="virtual"></a>
## `VIRTUAL()` ## `VIRTUAL()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L679) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L680)
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. 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.
You could also use it to validate a value before permuting and storing it. Checking password length before hashing it for example: You could also use it to validate a value before permuting and storing it. Checking password length before hashing it for example:
...@@ -246,10 +246,11 @@ Return type is mostly usefull for setups that rely on types like GraphQL. ...@@ -246,10 +246,11 @@ Return type is mostly usefull for setups that rely on types like GraphQL.
active: { active: {
type: new DataTypes.VIRTUAL(DataTypes.BOOLEAN, ['createdAt']), type: new DataTypes.VIRTUAL(DataTypes.BOOLEAN, ['createdAt']),
get: function() { get: function() {
return this.get('createdAt') > Date.now() - (7 * 24 * 60 * 60 * 1000) return this.get('createdAt') > Date.now() - (7 * 24 * 60 * 60 * 1000)
} }
} }
} }
```
In the above code the password is stored plainly in the password field so it can be validated, but is never stored in the DB. In the above code the password is stored plainly in the password field so it can be validated, but is never stored in the DB.
__Aliases:__ NONE __Aliases:__ NONE
...@@ -258,7 +259,7 @@ __Aliases:__ NONE ...@@ -258,7 +259,7 @@ __Aliases:__ NONE
<a name="enum"></a> <a name="enum"></a>
## `ENUM()` ## `ENUM()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L695) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L696)
An enumeration. `DataTypes.ENUM('value', 'another value')`. An enumeration. `DataTypes.ENUM('value', 'another value')`.
...@@ -266,7 +267,7 @@ An enumeration. `DataTypes.ENUM('value', 'another value')`. ...@@ -266,7 +267,7 @@ An enumeration. `DataTypes.ENUM('value', 'another value')`.
<a name="array"></a> <a name="array"></a>
## `ARRAY()` ## `ARRAY()`
[View code](https://github.com/sequelize/sequelize/blob/95f8fc2783814cd61ec1a8d623b23cd6a7cd5e17/lib/data-types.js#L719) [View code](https://github.com/sequelize/sequelize/blob/80e819723b3f24e0be5e8bd299a5b8bd66d47945/lib/data-types.js#L720)
An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in postgres. An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in postgres.
*** ***
......
...@@ -667,10 +667,11 @@ UUIDV4.prototype.validate = function(value) { ...@@ -667,10 +667,11 @@ UUIDV4.prototype.validate = function(value) {
* active: { * active: {
* type: new DataTypes.VIRTUAL(DataTypes.BOOLEAN, ['createdAt']), * type: new DataTypes.VIRTUAL(DataTypes.BOOLEAN, ['createdAt']),
* get: function() { * get: function() {
* return this.get('createdAt') > Date.now() - (7 * 24 * 60 * 60 * 1000) * return this.get('createdAt') > Date.now() - (7 * 24 * 60 * 60 * 1000)
* } * }
* } * }
* } * }
* ```
* *
* In the above code the password is stored plainly in the password field so it can be validated, but is never stored in the DB. * In the above code the password is stored plainly in the password field so it can be validated, but is never stored in the DB.
* @property VIRTUAL * @property VIRTUAL
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!