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

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