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

Commit d566c25e by Simon Schick Committed by Erik Seliger

docs(data-types): fix param locations (#10586)

1 parent 7f00a55b
...@@ -48,14 +48,12 @@ ABSTRACT.prototype.dialectTypes = ''; ...@@ -48,14 +48,12 @@ ABSTRACT.prototype.dialectTypes = '';
/** /**
* STRING A variable length string * STRING A variable length string
*
* @param {number} [length=255] length of string
* @param {boolean} [binary=false] Is this binary?
*
* @namespace DataTypes.STRING
*
*/ */
class STRING extends ABSTRACT { class STRING extends ABSTRACT {
/**
* @param {number} [length=255] length of string
* @param {boolean} [binary=false] Is this binary?
*/
constructor(length, binary) { constructor(length, binary) {
super(); super();
const options = typeof length === 'object' && length || { length, binary }; const options = typeof length === 'object' && length || { length, binary };
...@@ -89,13 +87,12 @@ class STRING extends ABSTRACT { ...@@ -89,13 +87,12 @@ class STRING extends ABSTRACT {
/** /**
* CHAR A fixed length string * CHAR A fixed length string
*
* @param {number} [length=255] length of string
* @param {boolean} [binary=false] Is this binary?
*
* @namespace DataTypes.CHAR
*/ */
class CHAR extends STRING { class CHAR extends STRING {
/**
* @param {number} [length=255] length of string
* @param {boolean} [binary=false] Is this binary?
*/
constructor(length, binary) { constructor(length, binary) {
super(typeof length === 'object' && length || { length, binary }); super(typeof length === 'object' && length || { length, binary });
} }
...@@ -106,12 +103,11 @@ class CHAR extends STRING { ...@@ -106,12 +103,11 @@ class CHAR extends STRING {
/** /**
* Unlimited length TEXT column * Unlimited length TEXT column
*
* @param {string} [length=''] could be tiny, medium, long.
*
* @namespace DataTypes.TEXT
*/ */
class TEXT extends ABSTRACT { class TEXT extends ABSTRACT {
/**
* @param {string} [length=''] could be tiny, medium, long.
*/
constructor(length) { constructor(length) {
super(); super();
const options = typeof length === 'object' && length || { length }; const options = typeof length === 'object' && length || { length };
...@@ -143,7 +139,6 @@ class TEXT extends ABSTRACT { ...@@ -143,7 +139,6 @@ class TEXT extends ABSTRACT {
* Original case is preserved but acts case-insensitive when comparing values (such as when finding or unique constraints). * Original case is preserved but acts case-insensitive when comparing values (such as when finding or unique constraints).
* Only available in Postgres and SQLite. * Only available in Postgres and SQLite.
* *
* @namespace DataTypes.CITEXT
*/ */
class CITEXT extends ABSTRACT { class CITEXT extends ABSTRACT {
toSql() { toSql() {
...@@ -159,18 +154,17 @@ class CITEXT extends ABSTRACT { ...@@ -159,18 +154,17 @@ class CITEXT extends ABSTRACT {
/** /**
* Base number type which is used to build other types * Base number type which is used to build other types
*
* @param {Object} options type options
* @param {string|number} [options.length] length of type, like `INT(4)`
* @param {boolean} [options.zerofill] Is zero filled?
* @param {boolean} [options.unsigned] Is unsigned?
* @param {string|number} [options.decimals] number of decimal points, used with length `FLOAT(5, 4)`
* @param {string|number} [options.precision] defines precision for decimal type
* @param {string|number} [options.scale] defines scale for decimal type
*
* @namespace DataTypes.NUMBER
*/ */
class NUMBER extends ABSTRACT { class NUMBER extends ABSTRACT {
/**
* @param {Object} options type options
* @param {string|number} [options.length] length of type, like `INT(4)`
* @param {boolean} [options.zerofill] Is zero filled?
* @param {boolean} [options.unsigned] Is unsigned?
* @param {string|number} [options.decimals] number of decimal points, used with length `FLOAT(5, 4)`
* @param {string|number} [options.precision] defines precision for decimal type
* @param {string|number} [options.scale] defines scale for decimal type
*/
constructor(options = {}) { constructor(options = {}) {
super(); super();
if (typeof options === 'number') { if (typeof options === 'number') {
...@@ -242,10 +236,6 @@ class NUMBER extends ABSTRACT { ...@@ -242,10 +236,6 @@ class NUMBER extends ABSTRACT {
/** /**
* A 32 bit integer * A 32 bit integer
*
* @param {string|number} [length] Integer length, INT(12)
*
* @namespace DataTypes.INTEGER
*/ */
class INTEGER extends NUMBER { class INTEGER extends NUMBER {
validate(value) { validate(value) {
...@@ -258,53 +248,36 @@ class INTEGER extends NUMBER { ...@@ -258,53 +248,36 @@ class INTEGER extends NUMBER {
/** /**
* A 8 bit integer * A 8 bit integer
*
* @param {string|number} [length] Integer length
*
* @namespace DataTypes.TINYINT
*/ */
class TINYINT extends INTEGER { class TINYINT extends INTEGER {
} }
/** /**
* A 16 bit integer * A 16 bit integer
*
* @param {string|number} [length] Integer length
*
* @namespace DataTypes.SMALLINT
*/ */
class SMALLINT extends INTEGER { class SMALLINT extends INTEGER {
} }
/** /**
* A 24 bit integer * A 24 bit integer
*
* @param {string|number} [length] Integer length
*
* @namespace DataTypes.MEDIUMINT
*/ */
class MEDIUMINT extends INTEGER { class MEDIUMINT extends INTEGER {
} }
/** /**
* A 64 bit integer * A 64 bit integer
*
* @param {string|number} [length] Integer length
*
* @namespace DataTypes.BIGINT
*/ */
class BIGINT extends INTEGER { class BIGINT extends INTEGER {
} }
/** /**
* Floating point number (4-byte precision). * Floating point number (4-byte precision).
*
* @param {string|number} [length] length of type, like `FLOAT(4)`
* @param {string|number} [decimals] number of decimal points, used with length `FLOAT(5, 4)`
*
* @namespace DataTypes.FLOAT
*/ */
class FLOAT extends NUMBER { class FLOAT extends NUMBER {
/**
* @param {string|number} [length] length of type, like `FLOAT(4)`
* @param {string|number} [decimals] number of decimal points, used with length `FLOAT(5, 4)`
*/
constructor(length, decimals) { constructor(length, decimals) {
super(typeof length === 'object' && length || { length, decimals }); super(typeof length === 'object' && length || { length, decimals });
} }
...@@ -318,13 +291,12 @@ class FLOAT extends NUMBER { ...@@ -318,13 +291,12 @@ class FLOAT extends NUMBER {
/** /**
* Floating point number (4-byte precision). * Floating point number (4-byte precision).
*
* @param {string|number} [length] length of type, like `REAL(4)`
* @param {string|number} [decimals] number of decimal points, used with length `REAL(5, 4)`
*
* @namespace DataTypes.REAL
*/ */
class REAL extends NUMBER { class REAL extends NUMBER {
/**
* @param {string|number} [length] length of type, like `REAL(4)`
* @param {string|number} [decimals] number of decimal points, used with length `REAL(5, 4)`
*/
constructor(length, decimals) { constructor(length, decimals) {
super(typeof length === 'object' && length || { length, decimals }); super(typeof length === 'object' && length || { length, decimals });
} }
...@@ -332,13 +304,12 @@ class REAL extends NUMBER { ...@@ -332,13 +304,12 @@ class REAL extends NUMBER {
/** /**
* Floating point number (8-byte precision). * Floating point number (8-byte precision).
*
* @param {string|number} [length] length of type, like `DOUBLE PRECISION(25)`
* @param {string|number} [decimals] number of decimal points, used with length `DOUBLE PRECISION(25, 10)`
*
* @namespace DataTypes.DOUBLE
*/ */
class DOUBLE extends NUMBER { class DOUBLE extends NUMBER {
/**
* @param {string|number} [length] length of type, like `DOUBLE PRECISION(25)`
* @param {string|number} [decimals] number of decimal points, used with length `DOUBLE PRECISION(25, 10)`
*/
constructor(length, decimals) { constructor(length, decimals) {
super(typeof length === 'object' && length || { length, decimals }); super(typeof length === 'object' && length || { length, decimals });
} }
...@@ -346,13 +317,12 @@ class DOUBLE extends NUMBER { ...@@ -346,13 +317,12 @@ class DOUBLE extends NUMBER {
/** /**
* Decimal type, variable precision, take length as specified by user * Decimal type, variable precision, take length as specified by user
*
* @param {string|number} [precision] defines precision
* @param {string|number} [scale] defines scale
*
* @namespace DataTypes.DECIMAL
*/ */
class DECIMAL extends NUMBER { class DECIMAL extends NUMBER {
/**
* @param {string|number} [precision] defines precision
* @param {string|number} [scale] defines scale
*/
constructor(precision, scale) { constructor(precision, scale) {
super(typeof precision === 'object' && precision || { precision, scale }); super(typeof precision === 'object' && precision || { precision, scale });
} }
...@@ -398,8 +368,6 @@ for (const floating of [FLOAT, DOUBLE, REAL]) { ...@@ -398,8 +368,6 @@ for (const floating of [FLOAT, DOUBLE, REAL]) {
/** /**
* A boolean / tinyint column, depending on dialect * A boolean / tinyint column, depending on dialect
*
* @namespace DataTypes.BOOLEAN
*/ */
class BOOLEAN extends ABSTRACT { class BOOLEAN extends ABSTRACT {
toSql() { toSql() {
...@@ -437,7 +405,6 @@ BOOLEAN.parse = BOOLEAN.prototype._sanitize; ...@@ -437,7 +405,6 @@ BOOLEAN.parse = BOOLEAN.prototype._sanitize;
/** /**
* A time column * A time column
* *
* @namespace DataTypes.TIME
*/ */
class TIME extends ABSTRACT { class TIME extends ABSTRACT {
toSql() { toSql() {
...@@ -447,12 +414,11 @@ class TIME extends ABSTRACT { ...@@ -447,12 +414,11 @@ class TIME extends ABSTRACT {
/** /**
* Date column with timezone, default is UTC * Date column with timezone, default is UTC
*
* @param {string|number} [length] precision to allow storing milliseconds
*
* @namespace DataTypes.DATE
*/ */
class DATE extends ABSTRACT { class DATE extends ABSTRACT {
/**
* @param {string|number} [length] precision to allow storing milliseconds
*/
constructor(length) { constructor(length) {
super(); super();
const options = typeof length === 'object' && length || { length }; const options = typeof length === 'object' && length || { length };
...@@ -504,8 +470,6 @@ class DATE extends ABSTRACT { ...@@ -504,8 +470,6 @@ class DATE extends ABSTRACT {
/** /**
* A date only column (no timestamp) * A date only column (no timestamp)
*
* @namespace DataTypes.DATEONLY
*/ */
class DATEONLY extends ABSTRACT { class DATEONLY extends ABSTRACT {
toSql() { toSql() {
...@@ -534,8 +498,6 @@ class DATEONLY extends ABSTRACT { ...@@ -534,8 +498,6 @@ class DATEONLY extends ABSTRACT {
/** /**
* A key / value store column. Only available in Postgres. * A key / value store column. Only available in Postgres.
*
* @namespace DataTypes.HSTORE
*/ */
class HSTORE extends ABSTRACT { class HSTORE extends ABSTRACT {
validate(value) { validate(value) {
...@@ -548,8 +510,6 @@ class HSTORE extends ABSTRACT { ...@@ -548,8 +510,6 @@ class HSTORE extends ABSTRACT {
/** /**
* A JSON string column. Available in MySQL, Postgres and SQLite * A JSON string column. Available in MySQL, Postgres and SQLite
*
* @namespace DataTypes.JSON
*/ */
class JSONTYPE extends ABSTRACT { class JSONTYPE extends ABSTRACT {
validate() { validate() {
...@@ -562,29 +522,23 @@ class JSONTYPE extends ABSTRACT { ...@@ -562,29 +522,23 @@ class JSONTYPE extends ABSTRACT {
/** /**
* A binary storage JSON column. Only available in Postgres. * A binary storage JSON column. Only available in Postgres.
*
* @namespace DataTypes.JSONB
*/ */
class JSONB extends JSONTYPE { class JSONB extends JSONTYPE {
} }
/** /**
* A default value of the current timestamp * A default value of the current timestamp
*
* @namespace DataTypes.NOW
*/ */
class NOW extends ABSTRACT { class NOW extends ABSTRACT {
} }
/** /**
* Binary storage * Binary storage
*
* @param {string} [length=''] could be tiny, medium, long.
*
* @namespace DataTypes.BLOB
*
*/ */
class BLOB extends ABSTRACT { class BLOB extends ABSTRACT {
/**
* @param {string} [length=''] could be tiny, medium, long.
*/
constructor(length) { constructor(length) {
super(); super();
const options = typeof length === 'object' && length || { length }; const options = typeof length === 'object' && length || { length };
...@@ -643,12 +597,11 @@ BLOB.prototype.escape = false; ...@@ -643,12 +597,11 @@ BLOB.prototype.escape = false;
/** /**
* 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. See [the Postgres documentation](http://www.postgresql.org/docs/9.4/static/rangetypes.html) for more details * Only available in Postgres. See [the Postgres documentation](http://www.postgresql.org/docs/9.4/static/rangetypes.html) for more details
*
* @param {<DataTypes>} subtype A subtype for range, like RANGE(DATE)
*
* @namespace DataTypes.RANGE
*/ */
class RANGE extends ABSTRACT { class RANGE extends ABSTRACT {
/**
* @param {ABSTRACT} subtype A subtype for range, like RANGE(DATE)
*/
constructor(subtype) { constructor(subtype) {
super(); super();
const options = _.isPlainObject(subtype) ? subtype : { subtype }; const options = _.isPlainObject(subtype) ? subtype : { subtype };
...@@ -674,8 +627,6 @@ class RANGE extends ABSTRACT { ...@@ -674,8 +627,6 @@ class RANGE extends ABSTRACT {
/** /**
* A column storing a unique universal identifier. * A column storing a unique universal identifier.
* Use with `UUIDV1` or `UUIDV4` for default values. * Use with `UUIDV1` or `UUIDV4` for default values.
*
* @namespace DataTypes.UUID
*/ */
class UUID extends ABSTRACT { class UUID extends ABSTRACT {
validate(value, options) { validate(value, options) {
...@@ -688,8 +639,6 @@ class UUID extends ABSTRACT { ...@@ -688,8 +639,6 @@ class UUID extends ABSTRACT {
/** /**
* A default unique universal identifier generated following the UUID v1 standard * A default unique universal identifier generated following the UUID v1 standard
*
* @namespace DataTypes.UUIDV1
*/ */
class UUIDV1 extends ABSTRACT { class UUIDV1 extends ABSTRACT {
validate(value, options) { validate(value, options) {
...@@ -702,8 +651,6 @@ class UUIDV1 extends ABSTRACT { ...@@ -702,8 +651,6 @@ class UUIDV1 extends ABSTRACT {
/** /**
* A default unique universal identifier generated following the UUID v4 standard * A default unique universal identifier generated following the UUID v4 standard
*
* @namespace DataTypes.UUIDV4
*/ */
class UUIDV4 extends ABSTRACT { class UUIDV4 extends ABSTRACT {
validate(value, options) { validate(value, options) {
...@@ -753,13 +700,12 @@ class UUIDV4 extends ABSTRACT { ...@@ -753,13 +700,12 @@ class UUIDV4 extends ABSTRACT {
* } * }
* } * }
* *
* @param {<DataTypes>} [ReturnType] return type for virtual type
* @param {Array} [fields] array of fields this virtual type is dependent on
*
* @namespace DataTypes.VIRTUAL
*
*/ */
class VIRTUAL extends ABSTRACT { class VIRTUAL extends ABSTRACT {
/**
* @param {ABSTRACT} [ReturnType] return type for virtual type
* @param {Array} [fields] array of fields this virtual type is dependent on
*/
constructor(ReturnType, fields) { constructor(ReturnType, fields) {
super(); super();
if (typeof ReturnType === 'function') if (typeof ReturnType === 'function')
...@@ -778,13 +724,11 @@ class VIRTUAL extends ABSTRACT { ...@@ -778,13 +724,11 @@ class VIRTUAL extends ABSTRACT {
* DataTypes.ENUM({ * DataTypes.ENUM({
* values: ['value', 'another value'] * values: ['value', 'another value']
* }) * })
*
* @param {Array|Object} value either array of values or options object with values array. It also supports variadic values
*
* @namespace DataTypes.ENUM
*
*/ */
class ENUM extends ABSTRACT { class ENUM extends ABSTRACT {
/**
* @param {...any|{ values: any[] }|any[]} args either array of values or options object with values array. It also supports variadic values
*/
constructor(...args) { constructor(...args) {
super(); super();
const value = args[0]; const value = args[0];
...@@ -809,12 +753,11 @@ class ENUM extends ABSTRACT { ...@@ -809,12 +753,11 @@ class ENUM extends ABSTRACT {
* *
* @example * @example
* DataTypes.ARRAY(DataTypes.DECIMAL)`. * DataTypes.ARRAY(DataTypes.DECIMAL)`.
*
* @param {<DataTypes>} type type of array values
*
* @namespace DataTypes.ARRAY
*/ */
class ARRAY extends ABSTRACT { class ARRAY extends ABSTRACT {
/**
* @param {ABSTRACT} type type of array values
*/
constructor(type) { constructor(type) {
super(); super();
const options = _.isPlainObject(type) ? type : { type }; const options = _.isPlainObject(type) ? type : { type };
...@@ -867,7 +810,7 @@ class ARRAY extends ABSTRACT { ...@@ -867,7 +810,7 @@ class ARRAY extends ABSTRACT {
* ]}; * ]};
* *
* User.create({username: 'username', geometry: polygon }); * User.create({username: 'username', geometry: polygon });
*
* @example <caption>Create a new point with a custom SRID</caption> * @example <caption>Create a new point with a custom SRID</caption>
* const point = { * const point = {
* type: 'Point', * type: 'Point',
...@@ -877,13 +820,14 @@ class ARRAY extends ABSTRACT { ...@@ -877,13 +820,14 @@ class ARRAY extends ABSTRACT {
* *
* User.create({username: 'username', geometry: point }) * User.create({username: 'username', geometry: point })
* *
* @param {string} [type] Type of geometry data
* @param {string} [srid] SRID of type
* *
* @see {@link DataTypes.GEOGRAPHY} * @see {@link DataTypes.GEOGRAPHY}
* @namespace DataTypes.GEOMETRY
*/ */
class GEOMETRY extends ABSTRACT { class GEOMETRY extends ABSTRACT {
/**
* @param {string} [type] Type of geometry data
* @param {string} [srid] SRID of type
*/
constructor(type, srid) { constructor(type, srid) {
super(); super();
const options = _.isPlainObject(type) ? type : { type, srid }; const options = _.isPlainObject(type) ? type : { type, srid };
...@@ -921,13 +865,12 @@ GEOMETRY.prototype.escape = false; ...@@ -921,13 +865,12 @@ GEOMETRY.prototype.escape = false;
* DataTypes.GEOGRAPHY * DataTypes.GEOGRAPHY
* DataTypes.GEOGRAPHY('POINT') * DataTypes.GEOGRAPHY('POINT')
* DataTypes.GEOGRAPHY('POINT', 4326) * DataTypes.GEOGRAPHY('POINT', 4326)
*
* @param {string} [type] Type of geography data
* @param {string} [srid] SRID of type
*
* @namespace DataTypes.GEOGRAPHY
*/ */
class GEOGRAPHY extends ABSTRACT { class GEOGRAPHY extends ABSTRACT {
/**
* @param {string} [type] Type of geography data
* @param {string} [srid] SRID of type
*/
constructor(type, srid) { constructor(type, srid) {
super(); super();
const options = _.isPlainObject(type) ? type : { type, srid }; const options = _.isPlainObject(type) ? type : { type, srid };
...@@ -950,8 +893,6 @@ GEOGRAPHY.prototype.escape = false; ...@@ -950,8 +893,6 @@ GEOGRAPHY.prototype.escape = false;
* The cidr type holds an IPv4 or IPv6 network specification. Takes 7 or 19 bytes. * The cidr type holds an IPv4 or IPv6 network specification. Takes 7 or 19 bytes.
* *
* Only available for Postgres * Only available for Postgres
*
* @namespace DataTypes.CIDR
*/ */
class CIDR extends ABSTRACT { class CIDR extends ABSTRACT {
validate(value) { validate(value) {
...@@ -966,8 +907,6 @@ class CIDR extends ABSTRACT { ...@@ -966,8 +907,6 @@ class CIDR extends ABSTRACT {
* The INET type holds an IPv4 or IPv6 host address, and optionally its subnet. Takes 7 or 19 bytes * The INET type holds an IPv4 or IPv6 host address, and optionally its subnet. Takes 7 or 19 bytes
* *
* Only available for Postgres * Only available for Postgres
*
* @namespace DataTypes.INET
*/ */
class INET extends ABSTRACT { class INET extends ABSTRACT {
validate(value) { validate(value) {
...@@ -983,7 +922,6 @@ class INET extends ABSTRACT { ...@@ -983,7 +922,6 @@ class INET extends ABSTRACT {
* *
* Only available for Postgres * Only available for Postgres
* *
* @namespace DataTypes.MACADDR
*/ */
class MACADDR extends ABSTRACT { class MACADDR extends ABSTRACT {
validate(value) { validate(value) {
...@@ -1038,8 +976,6 @@ class MACADDR extends ABSTRACT { ...@@ -1038,8 +976,6 @@ class MACADDR extends ABSTRACT {
* } * }
* }) * })
* ``` * ```
*
* @namespace DataTypes
*/ */
const DataTypes = module.exports = { const DataTypes = module.exports = {
ABSTRACT, ABSTRACT,
...@@ -1082,7 +1018,6 @@ const DataTypes = module.exports = { ...@@ -1082,7 +1018,6 @@ const DataTypes = module.exports = {
CITEXT CITEXT
}; };
_.each(DataTypes, (dataType, name) => { _.each(DataTypes, (dataType, name) => {
// guard for aliases // guard for aliases
if (!dataType.hasOwnProperty('key')) { if (!dataType.hasOwnProperty('key')) {
......
...@@ -304,7 +304,7 @@ class Transaction { ...@@ -304,7 +304,7 @@ class Transaction {
} }
/** /**
* Please {@link Transaction.LOCK} * Please see {@link Transaction.LOCK}
*/ */
get LOCK() { get LOCK() {
return Transaction.LOCK; return Transaction.LOCK;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* *
* @param {Function} Class The class instance to wrap as invocable. * @param {Function} Class The class instance to wrap as invocable.
* @returns {Proxy} Wrapped class instance. * @returns {Proxy} Wrapped class instance.
* @private
*/ */
function classToInvokable(Class) { function classToInvokable(Class) {
return new Proxy(Class, { return new Proxy(Class, {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!