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

Commit f9595392 by Jan Aagaard Meier Committed by GitHub

Merge pull request #6226 from sequelize/doclets

Update jsdocs for doclets
2 parents 00bf32a3 f48758d6
dir: lib
packageJson: package.json
articles:
- Getting started: docs/articles/getting-started.md
branches:
- master
- doclets
......@@ -34,7 +34,10 @@ const HasOne = require('./has-one');
*
* In the API reference below, replace `Assocation(s)` with the actual name of your association, e.g. for `User.belongsToMany(Project)` the getter will be `user.getProjects()`.
*
* @mixin BelongsToMany
* @class BelongsToMany
* @memberof Associations
*
* @see {@link Model.belongsToMany}
*/
class BelongsToMany extends Association {
constructor(source, target, options) {
......@@ -203,39 +206,47 @@ class BelongsToMany extends Association {
* @param {Object} [options.where] An optional where clause to limit the associated models
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
* @param {String} [options.schema] Apply a schema on the related model
* @see {Model#findAll} for a full explanation of options
* @return {Promise<Array<Instance>>}
* @see {@link Model#findAll} for a full explanation of options
* @return {Promise<Array<Model>>}
* @method getAssociations
* @memberof Associations.BelongsToMany
* @instance
*/
get: 'get' + plural,
/**
* 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.
*
* @param {Array<Instance|String|Number>} [newAssociations] An array of persisted instances or primary key of instances to associate with this. Pass `null` or `undefined` to remove all associations.
* @param {Array<Model|String|Number>} [newAssociations] An array of persisted instances or primary key of instances to associate with this. Pass `null` or `undefined` to remove all associations.
* @param {Object} [options] Options passed to `through.findAll`, `bulkCreate`, `update` and `destroy`. Can also hold additional attributes for the join table
* @param {Object} [options.validate] Run validation for the join model
* @return {Promise}
* @method setAssociations
* @memberof Associations.BelongsToMany
* @instance
*/
set: 'set' + plural,
/**
* Associate several persisted instances with this.
*
* @param {Array<Instance|String|Number>} [newAssociations] An array of persisted instances or primary key of instances to associate with this.
* @param {Array<Model|String|Number>} [newAssociations] An array of persisted instances or primary key of instances to associate with this.
* @param {Object} [options] Options passed to `through.findAll`, `bulkCreate` and `update`. Can also hold additional attributes for the join table.
* @param {Object} [options.validate] Run validation for the join model.
* @return {Promise}
* @method addAssociations
* @memberof Associations.BelongsToMany
* @instance
*/
addMultiple: 'add' + plural,
/**
* Associate a persisted instance with this.
*
* @param {Instance|String|Number} [newAssociation] A persisted instance or primary key of instance to associate with this.
* @param {Model|String|Number} [newAssociation] A persisted instance or primary key of instance to associate with this.
* @param {Object} [options] Options passed to `through.findAll`, `bulkCreate` and `update`. Can also hold additional attributes for the join table.
* @param {Object} [options.validate] Run validation for the join model.
* @return {Promise}
* @method addAssociation
* @memberof Associations.BelongsToMany
* @instance
*/
add: 'add' + singular,
/**
......@@ -245,42 +256,52 @@ class BelongsToMany extends Association {
* @param {Object} [options] Options passed to create and add. Can also hold additional attributes for the join table
* @return {Promise}
* @method createAssociation
* @memberof Associations.BelongsToMany
* @instance
*/
create: 'create' + singular,
/**
* Un-associate the instance.
*
* @param {Instance|String|Number} [oldAssociated] Can be an Instance or its primary key
* @param {Model|String|Number} [oldAssociated] Can be an Instance or its primary key
* @param {Object} [options] Options passed to `through.destroy`
* @return {Promise}
* @method removeAssociation
* @memberof Associations.BelongsToMany
* @instance
*/
remove: 'remove' + singular,
/**
* Un-associate several instances.
*
* @param {Array<Instance|String|Number>} [oldAssociated] Can be an array of instances or their primary keys
* @param {Array<Model|String|Number>} [oldAssociated] Can be an array of instances or their primary keys
* @param {Object} [options] Options passed to `through.destroy`
* @return {Promise}
* @method removeAssociations
* @memberof Associations.BelongsToMany
* @instance
*/
removeMultiple: 'remove' + plural,
/**
* Check if an instance is associated with this.
*
* @param {Instance|String|Number} [instance] Can be an Instance or its primary key
* @param {Model|String|Number} [instance] Can be an Instance or its primary key
* @param {Object} [options] Options passed to getAssociations
* @return {Promise}
* @method hasAssociation
* @memberof Associations.BelongsToMany
* @instance
*/
hasSingle: 'has' + singular,
/**
* Check if all instances are associated with this.
*
* @param {Array<Instance|String|Number>} [instances] Can be an array of instances or their primary keys
* @param {Array<Model|String|Number>} [instances] Can be an array of instances or their primary keys
* @param {Object} [options] Options passed to getAssociations
* @return {Promise}
* @method hasAssociations
* @memberof Associations.BelongsToMany
* @instance
*/
hasAll: 'has' + plural,
/**
......@@ -289,8 +310,10 @@ class BelongsToMany extends Association {
* @param {Object} [options]
* @param {Object} [options.where] An optional where clause to limit the associated models
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
* @return {Promise<Int>}
* @return {Promise<Integer>}
* @method countAssociations
* @memberof Associations.BelongsToMany
* @instance
*/
count: 'count' + plural
};
......
......@@ -11,7 +11,10 @@ const Association = require('./base');
*
* In the API reference below, replace `Assocation` with the actual name of your association, e.g. for `User.belongsTo(Project)` the getter will be `user.getProject()`.
*
* @mixin BelongsTo
* @class BelongsTo
* @memberof Associations
*
* @see {@link Model.belongsTo}
*/
class BelongsTo extends Association {
constructor(source, target, options) {
......@@ -78,19 +81,21 @@ class BelongsTo extends Association {
* @param {Object} [options]
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false.
* @param {String} [options.schema] Apply a schema on the related model
* @see {Model#findOne} for a full explanation of options
* @return {Promise<Instance>}
* @see {@link Model.findOne} for a full explanation of options
* @return {Promise<Model>}
* @method getAssociation
* @memberof Associations.BelongsTo
*/
get: 'get' + singular,
/**
* Set the associated model.
*
* @param {Instance|String|Number} [newAssociation] An persisted instance or the primary key of an instance to associate with this. Pass `null` or `undefined` to remove the association.
* @param {Model|String|Number} [newAssociation] An persisted instance or the primary key of an instance to associate with this. Pass `null` or `undefined` to remove the association.
* @param {Object} [options] Options passed to `this.save`
* @param {Boolean} [options.save=true] Skip saving this after setting the foreign key if false.
* @return {Promise}
* @method setAssociation
* @memberof Associations.BelongsTo
*/
set: 'set' + singular,
/**
......@@ -98,9 +103,10 @@ class BelongsTo extends Association {
*
* @param {Object} [values]
* @param {Object} [options] Options passed to `target.create` and setAssociation.
* @see {Model#create} for a full explanation of options
* @see {@link Model#create} for a full explanation of options
* @return {Promise}
* @method createAssociation
* @memberof Associations.BelongsTo
*/
create: 'create' + singular
};
......
......@@ -10,7 +10,10 @@ const Association = require('./base');
*
* 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()`.
*
* @mixin HasMany
* @class HasMany
* @memberof Associations
*
* @see {@link Model.hasMany}
*/
class HasMany extends Association {
constructor(source, target, options) {
......@@ -97,39 +100,43 @@ class HasMany extends Association {
* @param {Object} [options.where] An optional where clause to limit the associated models
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
* @param {String} [options.schema] Apply a schema on the related model
* @see {Model#findAll} for a full explanation of options
* @return {Promise<Array<Instance>>}
* @see {@link Model#findAll} for a full explanation of options
* @return {Promise<Array<Model>>}
* @method getAssociations
* @memberof Associations.HasMany
*/
get: 'get' + plural,
/**
* Set the associated models by passing an array of persisted instances or their primary keys. Everything that is not in the passed array will be un-associated
*
* @param {Array<Instance|String|Number>} [newAssociations] An array of persisted instances or primary key of instances to associate with this. Pass `null` or `undefined` to remove all associations.
* @param {Array<Model|String|Number>} [newAssociations] An array of persisted instances or primary key of instances to associate with this. Pass `null` or `undefined` to remove all associations.
* @param {Object} [options] Options passed to `target.findAll` and `update`.
* @param {Object} [options.validate] Run validation for the join model
* @return {Promise}
* @method setAssociations
* @memberof Associations.HasMany
*/
set: 'set' + plural,
/**
* Associate several persisted instances with this.
*
* @param {Array<Instance|String|Number>} [newAssociations] An array of persisted instances or primary key of instances to associate with this.
* @param {Array<Model|String|Number>} [newAssociations] An array of persisted instances or primary key of instances to associate with this.
* @param {Object} [options] Options passed to `target.update`.
* @param {Object} [options.validate] Run validation for the join model.
* @return {Promise}
* @method addAssociations
* @memberof Associations.HasMany
*/
addMultiple: 'add' + plural,
/**
* Associate a persisted instance with this.
*
* @param {Instance|String|Number} [newAssociation] A persisted instance or primary key of instance to associate with this.
* @param {Model|String|Number} [newAssociation] A persisted instance or primary key of instance to associate with this.
* @param {Object} [options] Options passed to `target.update`.
* @param {Object} [options.validate] Run validation for the join model.
* @return {Promise}
* @method addAssociation
* @memberof Associations.HasMany
*/
add: 'add' + singular,
/**
......@@ -139,42 +146,47 @@ class HasMany extends Association {
* @param {Object} [options] Options passed to `target.create`.
* @return {Promise}
* @method createAssociation
* @memberof Associations.HasMany
*/
create: 'create' + singular,
/**
* Un-associate the instance.
*
* @param {Instance|String|Number} [oldAssociated] Can be an Instance or its primary key
* @param {Model|String|Number} [oldAssociated] Can be an Instance or its primary key
* @param {Object} [options] Options passed to `target.update`
* @return {Promise}
* @method removeAssociation
* @memberof Associations.HasMany
*/
remove: 'remove' + singular,
/**
* Un-associate several instances.
*
* @param {Array<Instance|String|Number>} [oldAssociatedArray] Can be an array of instances or their primary keys
* @param {Array<Model|String|Number>} [oldAssociatedArray] Can be an array of instances or their primary keys
* @param {Object} [options] Options passed to `through.destroy`
* @return {Promise}
* @method removeAssociations
* @memberof Associations.HasMany
*/
removeMultiple: 'remove' + plural,
/**
* Check if an instance is associated with this.
*
* @param {Instance|String|Number} [instance] Can be an Instance or its primary key
* @param {Model|String|Number} [instance] Can be an Instance or its primary key
* @param {Object} [options] Options passed to getAssociations
* @return {Promise}
* @method hasAssociation
* @memberof Associations.HasMany
*/
hasSingle: 'has' + singular,
/**
* Check if all instances are associated with this.
*
* @param {Array<Instance|String|Number>} [instances] Can be an array of instances or their primary keys
* @param {Array<Model|String|Number>} [instances] Can be an array of instances or their primary keys
* @param {Object} [options] Options passed to getAssociations
* @return {Promise}
* @method hasAssociations
* @memberof Associations.HasMany
*/
hasAll: 'has' + plural,
/**
......@@ -183,8 +195,9 @@ class HasMany extends Association {
* @param {Object} [options]
* @param {Object} [options.where] An optional where clause to limit the associated models
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
* @return {Promise<Int>}
* @return {Promise<Integer>}
* @method countAssociations
* @memberof Associations.HasMany
*/
count: 'count' + plural
};
......
......@@ -11,7 +11,10 @@ const Association = require('./base');
* 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.
*
* @mixin HasOne
* @class HasOne
* @memberof Associations
*
* @see {@link Model.hasOne}
*/
class HasOne extends Association {
constructor(srcModel, targetModel, options) {
......@@ -75,18 +78,20 @@ class HasOne extends Association {
* @param {Object} [options]
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
* @param {String} [options.schema] Apply a schema on the related model
* @see {Model#findOne} for a full explanation of options
* @return {Promise<Instance>}
* @see {@link Model#findOne} for a full explanation of options
* @return {Promise<Model>}
* @method getAssociation
* @memberof Associations.HasOne
*/
get: 'get' + singular,
/**
* Set the associated model.
*
* @param {Instance|String|Number} [newAssociation] An persisted instance or the primary key of a persisted instance to associate with this. Pass `null` or `undefined` to remove the association.
* @param {Model|String|Number} [newAssociation] An persisted instance or the primary key of a persisted instance to associate with this. Pass `null` or `undefined` to remove the association.
* @param {Object} [options] Options passed to getAssociation and `target.save`
* @return {Promise}
* @method setAssociation
* @memberof Associations.HasOne
*/
set: 'set' + singular,
/**
......@@ -94,9 +99,10 @@ class HasOne extends Association {
*
* @param {Object} [values]
* @param {Object} [options] Options passed to `target.create` and setAssociation.
* @see {Model#create} for a full explanation of options
* @see {@link Model#create} for a full explanation of options
* @return {Promise}
* @method createAssociation
* @memberof Associations.HasOne
*/
create: 'create' + singular
};
......
......@@ -83,7 +83,7 @@ const BelongsTo = require('./belongs-to');
*
* Note how we also specified `constraints: false` for profile picture. This is because we add a foreign key from user to picture (profilePictureId), and from picture to user (userId). If we were to add foreign keys to both, it would create a cyclic dependency, and sequelize would not know which table to create first, since user depends on picture, and picture depends on user. These kinds of problems are detected by sequelize before the models are synced to the database, and you will get an error along the lines of `Error: Cyclic dependency found. 'users' is dependent of itself`. If you encounter this, you should either disable some constraints, or rethink your associations completely.
*
* @mixin Associations
* @namespace Associations
* @name Associations
*/
const Mixin = {
......@@ -101,6 +101,8 @@ const Mixin = {
* @param {string} [options.onDelete='SET&nbsp;NULL|CASCADE'] SET NULL if foreignKey allows nulls, CASCADE if otherwise
* @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key.
* @returns {Associations.HasMany}
* @memberof Model
*/
hasMany(target, options) { // testhint options:none
if (!target.prototype || !(target.prototype instanceof this.sequelize.Model)) {
......@@ -180,6 +182,8 @@ const Mixin = {
* @param {string} [options.onDelete='SET&nbsp;NULL|CASCADE'] Cascade if this is a n:m, and set null if it is a 1:m
* @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key.
* @returns {Associations.BelongsToMany}
* @memberof Model
*/
belongsToMany(targetModel, options) { // testhint options:none
if (!targetModel.prototype || !(targetModel.prototype instanceof this.sequelize.Model)) {
......@@ -265,6 +269,8 @@ function singleLinked(Type) {
* @param {string} [options.onDelete='SET&nbsp;NULL|CASCADE'] SET NULL if foreignKey allows nulls, CASCADE if otherwise
* @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key.
* @returns {Associations.HasOne}
* @memberof Model
*/
Mixin.hasOne = singleLinked(HasOne);
......@@ -283,6 +289,8 @@ Mixin.hasOne = singleLinked(HasOne);
* @param {string} [options.onDelete='SET&nbsp;NULL|NO&nbsp;ACTION'] SET NULL if foreignKey allows nulls, NO ACTION if otherwise
* @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key.
* @returns {Associations.BelongsTo}
* @memberof Model
*/
Mixin.belongsTo = singleLinked(BelongsTo);
......
......@@ -53,7 +53,7 @@ const moment = require('moment');
* })
* ```
*
* @class DataTypes
* @namespace DataTypes
*/
function ABSTRACT() {}
......@@ -82,9 +82,8 @@ ABSTRACT.prototype.stringify = function stringify(value, options) {
/**
* A variable length string. Default length 255
*
* Available properties: `BINARY`
*
* @property STRING
* @property BINARY
* @memberof DataTypes
*/
function STRING(length, binary) {
const options = typeof length === 'object' && length || {length, binary};
......@@ -124,7 +123,7 @@ Object.defineProperty(STRING.prototype, 'BINARY', {
*
* Available properties: `BINARY`
*
* @property CHAR
* @memberof DataTypes
*/
function CHAR(length, binary) {
const options = typeof length === 'object' && length || {length, binary};
......@@ -141,7 +140,8 @@ CHAR.prototype.toSql = function toSql() {
/**
* An (un)limited length text column. Available lengths: `tiny`, `medium`, `long`
* @property TEXT
*
* @memberof DataTypes
*/
function TEXT(length) {
const options = typeof length === 'object' && length || {length};
......@@ -228,9 +228,9 @@ Object.defineProperty(NUMBER.prototype, 'ZEROFILL', {
/**
* A 32 bit integer.
*
* Available properties: `UNSIGNED`, `ZEROFILL`
*
* @property INTEGER
* @property UNSIGNED
* @property ZEROFILL
* @memberof DataTypes
*/
function INTEGER(length) {
const options = typeof length === 'object' && length || {length};
......@@ -253,9 +253,9 @@ INTEGER.prototype.validate = function validate(value) {
*
* Note: an attribute defined as `BIGINT` will be treated like a `string` due this [feature from node-postgres](https://github.com/brianc/node-postgres/pull/353) to prevent precision loss. To have this attribute as a `number`, this is a possible [workaround](https://github.com/sequelize/sequelize/issues/2383#issuecomment-58006083).
*
* Available properties: `UNSIGNED`, `ZEROFILL`
*
* @property BIGINT
* @property UNSIGNED
* @property ZEROFILL
* @memberof DataTypes
*/
function BIGINT(length) {
......@@ -277,9 +277,9 @@ BIGINT.prototype.validate = function validate(value) {
/**
* Floating point number (4-byte precision). Accepts one or two arguments for precision
*
* Available properties: `UNSIGNED`, `ZEROFILL`
*
* @property FLOAT
* @property UNSIGNED
* @property ZEROFILL
* @memberof DataTypes
*/
function FLOAT(length, decimals) {
const options = typeof length === 'object' && length || {length, decimals};
......@@ -300,9 +300,9 @@ FLOAT.prototype.validate = function validate(value) {
/**
* Floating point number (4-byte precision). Accepts one or two arguments for precision
*
* Available properties: `UNSIGNED`, `ZEROFILL`
*
* @property REAL
* @property UNSIGNED
* @property ZEROFILL
* @memberof DataTypes
*/
function REAL(length, decimals) {
const options = typeof length === 'object' && length || {length, decimals};
......@@ -316,9 +316,9 @@ REAL.prototype.key = REAL.key = 'REAL';
/**
* Floating point number (8-byte precision). Accepts one or two arguments for precision
*
* Available properties: `UNSIGNED`, `ZEROFILL`
*
* @property DOUBLE
* @property UNSIGNED
* @property ZEROFILL
* @memberof DataTypes
*/
function DOUBLE(length, decimals) {
const options = typeof length === 'object' && length || {length, decimals};
......@@ -332,9 +332,9 @@ DOUBLE.prototype.key = DOUBLE.key = 'DOUBLE PRECISION';
/**
* Decimal number. Accepts one or two arguments for precision
*
* Available properties: `UNSIGNED`, `ZEROFILL`
*
* @property DECIMAL
* @property UNSIGNED
* @property ZEROFILL
* @memberof DataTypes
*/
function DECIMAL(precision, scale) {
const options = typeof precision === 'object' && precision || {precision, scale};
......@@ -376,7 +376,8 @@ for (const floating of [FLOAT, DOUBLE, REAL]) {
/**
* A boolean / tinyint column, depending on dialect
* @property BOOLEAN
*
* @memberof DataTypes
*/
function BOOLEAN() {
if (!(this instanceof BOOLEAN)) return new BOOLEAN();
......@@ -397,7 +398,8 @@ BOOLEAN.prototype.validate = function validate(value) {
/**
* A time column
* @property TIME
*
* @memberof DataTypes
*/
function TIME() {
......@@ -412,7 +414,8 @@ TIME.prototype.toSql = function toSql() {
/**
* A datetime column
* @property DATE
*
* @memberof DataTypes
*/
function DATE(length) {
const options = typeof length === 'object' && length || {length};
......@@ -459,7 +462,8 @@ DATE.prototype._stringify = function _stringify(date, options) {
/**
* A date only column
* @property DATEONLY
*
* @memberof DataTypes
*/
function DATEONLY() {
......@@ -474,7 +478,8 @@ DATEONLY.prototype.toSql = function() {
/**
* A key / value column. Only available in postgres.
* @property HSTORE
*
* @memberof DataTypes
*/
function HSTORE() {
......@@ -493,7 +498,9 @@ HSTORE.prototype.validate = function validate(value) {
/**
* A JSON string column. Only available in postgres.
* @property JSON
*
* @function JSON
* @memberof DataTypes
*/
function JSONTYPE() {
if (!(this instanceof JSONTYPE)) return new JSONTYPE();
......@@ -511,7 +518,8 @@ JSONTYPE.prototype._stringify = function _stringify(value, options) {
/**
* A pre-processed JSON data column. Only available in postgres.
* @property JSONB
*
* @memberof DataTypes
*/
function JSONB() {
if (!(this instanceof JSONB)) return new JSONB();
......@@ -523,7 +531,8 @@ JSONB.prototype.key = JSONB.key = 'JSONB';
/**
* A default value of the current timestamp
* @property NOW
*
* @memberof DataTypes
*/
function NOW() {
if (!(this instanceof NOW)) return new NOW();
......@@ -535,7 +544,7 @@ NOW.prototype.key = NOW.key = 'NOW';
/**
* Binary storage. Available lengths: `tiny`, `medium`, `long`
*
* @property BLOB
* @memberof DataTypes
*/
function BLOB(length) {
const options = typeof length === 'object' && length || {length};
......@@ -588,7 +597,8 @@ BLOB.prototype._hexify = function _hexify(hex) {
* Range types are data types representing a range of values of some element type (called the range's subtype).
* Only available in postgres.
* See {@link http://www.postgresql.org/docs/9.4/static/rangetypes.html|Postgres documentation} for more details
* @property RANGE
*
* @memberof DataTypes
*/
function RANGE(subtype) {
......@@ -651,7 +661,8 @@ RANGE.prototype.validate = function validate(value) {
/**
* A column storing a unique universal identifier. Use with `UUIDV1` or `UUIDV4` for default values.
* @property UUID
*
* @memberof DataTypes
*/
function UUID() {
if (!(this instanceof UUID)) return new UUID();
......@@ -669,7 +680,8 @@ UUID.prototype.validate = function validate(value, options) {
/**
* A default unique universal identifier generated following the UUID v1 standard
* @property UUIDV1
*
* @memberof DataTypes
*/
function UUIDV1() {
......@@ -688,7 +700,8 @@ UUIDV1.prototype.validate = function validate(value, options) {
/**
* A default unique universal identifier generated following the UUID v4 standard
* @property UUIDV4
*
* @memberof DataTypes
*/
function UUIDV4() {
......@@ -744,8 +757,7 @@ UUIDV4.prototype.validate = function validate(value, options) {
* }
* ```
*
* @property VIRTUAL
* @alias NONE
* @memberof DataTypes
*/
function VIRTUAL(ReturnType, fields) {
if (!(this instanceof VIRTUAL)) return new VIRTUAL(ReturnType, fields);
......@@ -761,7 +773,7 @@ VIRTUAL.prototype.key = VIRTUAL.key = 'VIRTUAL';
/**
* An enumeration. `DataTypes.ENUM('value', 'another value')`.
*
* @property ENUM
* @memberof DataTypes
*/
function ENUM(value) {
const options = typeof value === 'object' && !Array.isArray(value) && value || {
......@@ -786,7 +798,8 @@ ENUM.prototype.validate = function validate(value) {
/**
* An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in postgres.
* @property ARRAY
*
* @memberof DataTypes
*/
function ARRAY(type) {
const options = _.isPlainObject(type) ? type : {type};
......@@ -866,7 +879,7 @@ const helpers = {
* });
* ```
*
* @property GEOMETRY
* @memberof DataTypes
*/
function GEOMETRY(type, srid) {
......@@ -889,7 +902,8 @@ GEOMETRY.prototype._stringify = function _stringify(value, options) {
/**
* A geography datatype represents two dimensional spacial objects in an elliptic coord system.
* @property GEOGRAPHY
*
* @memberof DataTypes
*/
function GEOGRAPHY(type, srid) {
......
......@@ -34,7 +34,14 @@ var util = require('util');
* });
* ```
*
* @return {object}
* @namespace Deferrable
* @memberof Sequelize
*
* @property INITIALLY_DEFERRED Defer constraints checks to the end of transactions.
* @property INITIALLY_IMMEDIATE Trigger the constraint checks immediately
* @property NOT Set the constraints to not deferred. This is the default in PostgreSQL and it make it impossible to dynamically defer the constraints within a transaction.
* @property SET_DEFERRED
* @property SET_IMMEDIATE
*/
var Deferrable = module.exports = {
INITIALLY_DEFERRED,
......@@ -50,12 +57,6 @@ ABSTRACT.prototype.toString = function() {
return this.toSql.apply(this, arguments);
};
/**
* A property that will defer constraints checks to the end of transactions.
*
* @property INITIALLY_DEFERRED
*/
function INITIALLY_DEFERRED() {
if (!(this instanceof INITIALLY_DEFERRED)) {
return new INITIALLY_DEFERRED();
......@@ -67,12 +68,6 @@ INITIALLY_DEFERRED.prototype.toSql = function() {
return 'DEFERRABLE INITIALLY DEFERRED';
};
/**
* A property that will trigger the constraint checks immediately
*
* @property INITIALLY_IMMEDIATE
*/
function INITIALLY_IMMEDIATE() {
if (!(this instanceof INITIALLY_IMMEDIATE)) {
return new INITIALLY_IMMEDIATE();
......@@ -84,14 +79,6 @@ INITIALLY_IMMEDIATE.prototype.toSql = function() {
return 'DEFERRABLE INITIALLY IMMEDIATE';
};
/**
* A property that will set the constraints to not deferred. This is
* the default in PostgreSQL and it make it impossible to dynamically
* defer the constraints within a transaction.
*
* @property NOT
*/
function NOT() {
if (!(this instanceof NOT)) {
return new NOT();
......@@ -103,14 +90,6 @@ NOT.prototype.toSql = function() {
return 'NOT DEFERRABLE';
};
/**
* A property that will trigger an additional query at the beginning of a
* transaction which sets the constraints to deferred.
*
* @param {Array} constraints An array of constraint names. Will defer all constraints by default.
* @property SET_DEFERRED
*/
function SET_DEFERRED(constraints) {
if (!(this instanceof SET_DEFERRED)) {
return new SET_DEFERRED(constraints);
......@@ -124,14 +103,6 @@ SET_DEFERRED.prototype.toSql = function(queryGenerator) {
return queryGenerator.setDeferredQuery(this.constraints);
};
/**
* A property that will trigger an additional query at the beginning of a
* transaction which sets the constraints to immediately.
*
* @param {Array} constraints An array of constraint names. Will defer all constraints by default.
* @property SET_IMMEDIATE
*/
function SET_IMMEDIATE(constraints) {
if (!(this instanceof SET_IMMEDIATE)) {
return new SET_IMMEDIATE(constraints);
......
......@@ -19,6 +19,7 @@ class AbstractQuery {
* Options
* skipUnescape: bool, skip unescaping $$
* skipValueReplace: bool, do not replace (but do unescape $$). Check correct syntax and if all values are available
* @private
*/
static formatBindParameters(sql, values, dialect, replacementFunc, options) {
if (!values) {
......@@ -94,7 +95,7 @@ class AbstractQuery {
* query.run('SELECT 1')
*
* @param {String} sql - The SQL query which should be executed.
* @api public
* @private
*/
run() {
throw new Error('The run method wasn\'t overwritten!');
......@@ -104,6 +105,7 @@ class AbstractQuery {
* Check the logging option of the instance and print deprecation warnings.
*
* @return {void}
* @private
*/
checkLoggingOption() {
if (this.options.logging === true) {
......@@ -116,6 +118,7 @@ class AbstractQuery {
* Get the attributes of an insert query, which contains the just inserted id.
*
* @return {String} The field name.
* @private
*/
getInsertIdField() {
return 'insertId';
......@@ -127,6 +130,7 @@ class AbstractQuery {
*
* @param {String} attribute An attribute of a SQL query. (?)
* @return {String} The found tableName / alias.
* @private
*/
findTableNameInAttribute(attribute) {
if (!this.options.include) {
......@@ -353,6 +357,7 @@ class AbstractQuery {
* ]
* }
* ]
* @private
*/
static _groupJoinData(rows, includeOptions, options) {
......
......@@ -5,6 +5,7 @@
@class QueryInterface
@static
@private
*/
/**
......@@ -17,6 +18,7 @@
@param {String} attributeName The name of the attribute that we want to remove.
@param {Object} options
@param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@private
*/
var removeColumn = function(tableName, attributeName, options) {
var self = this;
......
......@@ -128,6 +128,7 @@ class Query extends AbstractQuery {
* ])
*
* @param {Array} data - The result of the query execution.
* @private
*/
formatResults(data) {
let result = this.instance;
......
......@@ -17,6 +17,7 @@ const parserMap = new Map();
*
* @extends AbstractConnectionManager
* @return Class<ConnectionManager>
* @private
*/
class ConnectionManager extends AbstractConnectionManager {
......@@ -65,6 +66,7 @@ class ConnectionManager extends AbstractConnectionManager {
* Also set proper timezone once conection is connected
*
* @return Promise<Connection>
* @private
*/
connect(config) {
const connectionConfig = {
......
......@@ -302,6 +302,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table.
* @param {String} schemaName The name of the schema.
* @return {String} The generated sql query.
* @private
*/
getForeignKeysQuery(tableName, schemaName) {
return "SELECT CONSTRAINT_NAME as constraint_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME = '" + tableName + /* jshint ignore: line */
......@@ -314,6 +315,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table.
* @param {String} columnName The name of the column.
* @return {String} The generated sql query.
* @private
*/
getForeignKeyQuery(table, columnName) {
let tableName = table.tableName || table;
......@@ -335,6 +337,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table.
* @param {String} foreignKey The name of the foreign key constraint.
* @return {String} The generated sql query.
* @private
*/
dropForeignKeyQuery(tableName, foreignKey) {
return 'ALTER TABLE ' + this.quoteTable(tableName) + ' DROP FOREIGN KEY ' + this.quoteIdentifier(foreignKey) + ';';
......
......@@ -5,6 +5,7 @@
@class QueryInterface
@static
@private
*/
const _ = require('lodash');
......@@ -18,6 +19,7 @@ const _ = require('lodash');
@param {String} tableName The name of the table.
@param {String} columnName The name of the attribute that we want to remove.
@param {Object} options
@private
*/
function removeColumn(tableName, columnName, options) {
options = options || {};
......
......@@ -84,6 +84,7 @@ class Query extends AbstractQuery {
* ])
*
* @param {Array} data - The result of the query execution.
* @private
*/
formatResults(data) {
let result = this.instance;
......
......@@ -769,6 +769,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table.
* @param {String} schemaName The name of the schema.
* @return {String} The generated sql query.
* @private
*/
getForeignKeysQuery(tableName, schemaName) {
return 'SELECT conname as constraint_name, pg_catalog.pg_get_constraintdef(r.oid, true) as condef FROM pg_catalog.pg_constraint r ' +
......@@ -781,6 +782,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table.
* @param {String} foreignKey The name of the foreign key constraint.
* @return {String} The generated sql query.
* @private
*/
dropForeignKeyQuery(tableName, foreignKey) {
return 'ALTER TABLE ' + this.quoteTable(tableName) + ' DROP CONSTRAINT ' + this.quoteIdentifier(foreignKey) + ';';
......
......@@ -26,6 +26,7 @@ class Query extends AbstractQuery {
/**
* rewrite query with parameters
* @private
*/
static formatBindParameters(sql, values, dialect) {
let bindParam = [];
......
......@@ -341,6 +341,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table.
* @param {String} schemaName The name of the schema.
* @return {String} The generated sql query.
* @private
*/
getForeignKeysQuery(tableName, schemaName) {
return `PRAGMA foreign_key_list(${tableName})`;
......
......@@ -8,6 +8,7 @@ const Promise = require('../../promise');
@class QueryInterface
@static
@private
*/
/**
......@@ -24,6 +25,7 @@ const Promise = require('../../promise');
@param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@since 1.6.0
@private
*/
function removeColumn(tableName, attributeName, options) {
options = options || {};
......@@ -54,6 +56,7 @@ exports.removeColumn = removeColumn;
@param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@since 1.6.0
@private
*/
function changeColumn(tableName, attributes, options) {
const attributeName = Object.keys(attributes)[0];
......@@ -86,6 +89,7 @@ exports.changeColumn = changeColumn;
@param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@since 1.6.0
@private
*/
function renameColumn(tableName, attrNameBefore, attrNameAfter, options) {
options = options || {};
......
......@@ -32,6 +32,7 @@ class Query extends AbstractQuery {
/**
* rewrite query with parameters
* @private
*/
static formatBindParameters(sql, values, dialect) {
let bindParam;
......
......@@ -4,15 +4,16 @@
* 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.
*
* @fileOverview The Error Objects produced by Sequelize.
* @class Errors
* This means that errors can be accessed using `Sequelize.ValidationError` or `sequelize.ValidationError
*
* @namespace Errors
*/
/**
* The Base Error all Sequelize Errors inherit from.
*
* @constructor
* @alias Error
* @memberof Errors
*/
class BaseError extends Error {
constructor(message) {
......@@ -30,7 +31,7 @@ exports.BaseError = BaseError;
* @param {string} message Error message
*
* @extends BaseError
* @constructor
* @memberof Errors
*/
class SequelizeScopeError extends BaseError {
constructor(parent) {
......@@ -48,17 +49,15 @@ exports.SequelizeScopeError = SequelizeScopeError;
* @param {Array} [errors] Array of ValidationErrorItem objects describing the validation errors
*
* @extends BaseError
* @constructor
* @memberof Errors
*
* @property errors An array of ValidationErrorItems
*/
class ValidationError extends BaseError {
constructor(message, errors) {
super(message);
this.name = 'SequelizeValidationError';
this.message = 'Validation Error';
/**
* An array of ValidationErrorItems
* @member errors
*/
this.errors = errors || [];
// Use provided error message if available...
......@@ -91,43 +90,23 @@ exports.ValidationError = ValidationError;
/**
* A base class for all database related errors.
* @extends BaseError
* @constructor
* @class DatabaseError
* @memberof Errors
*
* @property parent The database specific error which triggered this one
* @property sql The SQL that triggered the error
* @property message The message from the DB.
* @property fields The fields of the unique constraint
* @property value The value(s) which triggered the error
* @property index The name of the index that triggered the error
*/
class DatabaseError extends BaseError {
constructor(parent) {
super(parent.message);
this.name = 'SequelizeDatabaseError';
/**
* The database specific error which triggered this one
* @member parent
*/
this.parent = parent;
this.original = parent;
/**
* The SQL that triggered the error
* @member sql
*/
this.sql = parent.sql;
/**
* The message from the DB.
* @member message
* @name message
*/
/**
* The fields of the unique constraint
* @member fields
* @name fields
*/
/**
* The value(s) which triggered the error
* @member value
* @name value
*/
/**
* The name of the index that triggered the error
* @member index
* @name index
*/
}
}
exports.DatabaseError = DatabaseError;
......@@ -135,7 +114,7 @@ exports.DatabaseError = DatabaseError;
/**
* Thrown when a database query times out because of a deadlock
* @extends DatabaseError
* @constructor
* @memberof Errors
*/
class TimeoutError extends DatabaseError {
constructor(parent) {
......@@ -148,7 +127,10 @@ exports.TimeoutError = TimeoutError;
/**
* Thrown when a unique constraint is violated in the database
* @extends DatabaseError
* @constructor
* @memberof Errors
*
* @property
* @property sql
*/
class UniqueConstraintError extends ValidationError {
constructor(options) {
......@@ -172,7 +154,7 @@ exports.UniqueConstraintError = UniqueConstraintError;
/**
* Thrown when a foreign key constraint is violated in the database
* @extends DatabaseError
* @constructor
* @memberof Errors
*/
class ForeignKeyConstraintError extends DatabaseError {
constructor(options) {
......@@ -194,7 +176,7 @@ exports.ForeignKeyConstraintError = ForeignKeyConstraintError;
/**
* Thrown when an exclusion constraint is violated in the database
* @extends DatabaseError
* @constructor
* @memberof Errors
*/
class ExclusionConstraintError extends DatabaseError {
constructor(options) {
......@@ -220,7 +202,7 @@ exports.ExclusionConstraintError = ExclusionConstraintError;
* @param {string} type The type of the validation error
* @param {string} path The field that triggered the validation error
* @param {string} value The value that generated the error
* @constructor
* @memberof Errors
*/
class ValidationErrorItem {
constructor(message, type, path, value) {
......@@ -235,16 +217,14 @@ exports.ValidationErrorItem = ValidationErrorItem;
/**
* A base class for all connection related errors.
* @extends BaseError
* @constructor
* @memberof Errors
*
* @property parent The connection specific error which triggered this one
*/
class ConnectionError extends BaseError {
constructor(parent) {
super(parent ? parent.message : '');
this.name = 'SequelizeConnectionError';
/**
* The connection specific error which triggered this one
* @member parent
*/
this.parent = parent;
this.original = parent;
}
......@@ -254,7 +234,7 @@ exports.ConnectionError = ConnectionError;
/**
* Thrown when a connection to a database is refused
* @extends ConnectionError
* @constructor
* @memberof Errors
*/
class ConnectionRefusedError extends ConnectionError {
constructor(parent) {
......@@ -267,7 +247,7 @@ exports.ConnectionRefusedError = ConnectionRefusedError;
/**
* Thrown when a connection to a database is refused due to insufficient privileges
* @extends ConnectionError
* @constructor
* @memberof Errors
*/
class AccessDeniedError extends ConnectionError {
constructor(parent) {
......@@ -280,7 +260,7 @@ exports.AccessDeniedError = AccessDeniedError;
/**
* Thrown when a connection to a database has a hostname that was not found
* @extends ConnectionError
* @constructor
* @memberof Errors
*/
class HostNotFoundError extends ConnectionError {
constructor(parent) {
......@@ -293,7 +273,7 @@ exports.HostNotFoundError = HostNotFoundError;
/**
* Thrown when a connection to a database has a hostname that was not reachable
* @extends ConnectionError
* @constructor
* @memberof Errors
*/
class HostNotReachableError extends ConnectionError {
constructor(parent) {
......@@ -306,7 +286,7 @@ exports.HostNotReachableError = HostNotReachableError;
/**
* Thrown when a connection to a database has invalid values for any of the connection parameters
* @extends ConnectionError
* @constructor
* @memberof Errors
*/
class InvalidConnectionError extends ConnectionError {
constructor(parent) {
......@@ -319,7 +299,7 @@ exports.InvalidConnectionError = InvalidConnectionError;
/**
* Thrown when a connection to a database times out
* @extends ConnectionError
* @constructor
* @memberof Errors
*/
class ConnectionTimedOutError extends ConnectionError {
constructor(parent) {
......@@ -332,7 +312,7 @@ exports.ConnectionTimedOutError = ConnectionTimedOutError;
/**
* Thrown when a some problem occurred with Instance methods (see message for details)
* @extends BaseError
* @constructor
* @memberof Errors
*/
class InstanceError extends BaseError {
constructor(message) {
......@@ -346,7 +326,7 @@ exports.InstanceError = InstanceError;
/**
* Thrown when a record was not found, Usually used with rejectOnEmpty mode (see message for details)
* @extends BaseError
* @constructor
* @memberof Errors
*/
class EmptyResultError extends BaseError {
constructor(message) {
......
......@@ -4,38 +4,6 @@ const Utils = require('./utils');
const Promise = require('./promise');
const debug = Utils.getLogger().debugContext('hooks');
/**
* Hooks are function that are called before and after (bulk-) creation/updating/deletion and validation. Hooks can be added to you models in three ways:
*
* 1. By specifying them as options in `sequelize.define`
* 2. By calling `hook()` with a string and your hook handler function
* 3. By calling the function with the same name as the hook you want
* ```js
* // Method 1
* sequelize.define(name, { attributes }, {
* hooks: {
* beforeBulkCreate() {
* // can be a single function
* },
* beforeValidate: [
* function() {},
* function() {} // Or an array of several
* ]
* }
* })
*
* // Method 2
* Model.hook('afterDestroy', function () {})
*
* // Method 3
* Model.afterBulkUpdate(function () {})
* ```
*
* @see {Sequelize#define}
* @mixin Hooks
* @name Hooks
*/
const hookTypes = {
beforeValidate: {params: 2},
afterValidate: {params: 2},
......@@ -88,6 +56,7 @@ exports.hookAliases = hookAliases;
/**
* get array of current hook and its proxied hooks combined
* @private
*/
const getProxiedHooks = (hookType) => (
hookTypes[hookType].proxies
......@@ -160,11 +129,12 @@ const Hooks = {
/**
* Add a hook to the model
*
* @param {String} hooktype
* @param {String} hookType
* @param {String} [name] Provide a name for the hook function. It can be used to remove the hook later or to order hooks based on some sort of priority system in the future.
* @param {Function} fn The hook function
*
* @alias hook
* @memberOf Sequelize
* @memberOf Sequelize.Model
*/
addHook(hookType, name, fn) {
if (typeof name === 'function') {
......@@ -191,6 +161,9 @@ const Hooks = {
*
* @param {String} hookType
* @param {String|Function} name
*
* @memberOf Sequelize
* @memberOf Sequelize.Model
*/
removeHook(hookType, name) {
hookType = hookAliases[hookType] || hookType;
......@@ -218,12 +191,14 @@ const Hooks = {
return this;
},
/*
/**
* Check whether the mode has any hooks of this type
*
* @param {String} hookType
*
* @alias hasHooks
* @memberOf Sequelize
* @memberOf Sequelize.Model
*/
hasHook(hookType) {
return this.options.hooks[hookType] && !!this.options.hooks[hookType].length;
......@@ -249,6 +224,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with instance, options
* @name beforeValidate
* @memberOf Sequelize.Model
*/
/**
......@@ -256,6 +232,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with instance, options
* @name afterValidate
* @memberOf Sequelize.Model
*/
/**
......@@ -264,6 +241,7 @@ exports.applyTo = applyTo;
* @param {Function} fn A callback function that is called with instance, options, error. Error is the
* SequelizeValidationError. If the callback throws an error, it will replace the original validation error.
* @name validationFailed
* @memberOf Sequelize.Model
*/
/**
......@@ -271,6 +249,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with attributes, options
* @name beforeCreate
* @memberOf Sequelize.Model
*/
/**
......@@ -278,6 +257,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with attributes, options
* @name afterCreate
* @memberOf Sequelize.Model
*/
/**
......@@ -285,6 +265,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with attributes, options
* @name beforeSave
* @memberOf Sequelize.Model
*/
/**
......@@ -292,6 +273,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with attributes, options
* @name beforeUpsert
* @memberOf Sequelize.Model
*/
/**
......@@ -299,6 +281,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with attributes, options
* @name afterUpsert
* @memberOf Sequelize.Model
*/
/**
......@@ -306,6 +289,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with attributes, options
* @name afterSave
* @memberOf Sequelize.Model
*/
/**
......@@ -315,6 +299,7 @@ exports.applyTo = applyTo;
*
* @name beforeDestroy
* @alias beforeDelete
* @memberOf Sequelize.Model
*/
/**
......@@ -324,6 +309,7 @@ exports.applyTo = applyTo;
*
* @name afterDestroy
* @alias afterDelete
* @memberOf Sequelize.Model
*/
/**
......@@ -332,6 +318,7 @@ exports.applyTo = applyTo;
* @param {Function} fn A callback function that is called with instance, options
*
* @name beforeRestore
* @memberOf Sequelize.Model
*/
/**
......@@ -340,6 +327,7 @@ exports.applyTo = applyTo;
* @param {Function} fn A callback function that is called with instance, options
*
* @name afterRestore
* @memberOf Sequelize.Model
*/
/**
......@@ -347,6 +335,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with instance, options
* @name beforeUpdate
* @memberOf Sequelize.Model
*/
/**
......@@ -354,6 +343,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with instance, options
* @name afterUpdate
* @memberOf Sequelize.Model
*/
/**
......@@ -361,6 +351,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with instances, options
* @name beforeBulkCreate
* @memberOf Sequelize.Model
*/
/**
......@@ -368,6 +359,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with instances, options
* @name afterBulkCreate
* @memberOf Sequelize.Model
*/
/**
......@@ -377,6 +369,7 @@ exports.applyTo = applyTo;
*
* @name beforeBulkDestroy
* @alias beforeBulkDelete
* @memberOf Sequelize.Model
*/
/**
......@@ -386,6 +379,7 @@ exports.applyTo = applyTo;
*
* @name afterBulkDestroy
* @alias afterBulkDelete
* @memberOf Sequelize.Model
*/
/**
......@@ -394,6 +388,7 @@ exports.applyTo = applyTo;
* @param {Function} fn A callback function that is called with options
*
* @name beforeBulkRestore
* @memberOf Sequelize.Model
*/
/**
......@@ -402,6 +397,7 @@ exports.applyTo = applyTo;
* @param {Function} fn A callback function that is called with options
*
* @name afterBulkRestore
* @memberOf Sequelize.Model
*/
/**
......@@ -409,6 +405,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options
* @name beforeBulkUpdate
* @memberOf Sequelize.Model
*/
/**
......@@ -416,6 +413,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options
* @name afterBulkUpdate
* @memberOf Sequelize.Model
*/
/**
......@@ -423,6 +421,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options
* @name beforeFind
* @memberOf Sequelize.Model
*/
/**
......@@ -430,6 +429,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options
* @name beforeFindAfterExpandIncludeAll
* @memberOf Sequelize.Model
*/
/**
......@@ -437,6 +437,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options
* @name beforeFindAfterOptions
* @memberOf Sequelize.Model
*/
/**
......@@ -444,6 +445,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with instance(s), options
* @name afterFind
* @memberOf Sequelize.Model
*/
/**
......@@ -451,6 +453,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options
* @name beforeCount
* @memberOf Sequelize.Model
*/
/**
......@@ -458,6 +461,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with attributes, options
* @name beforeDefine
* @memberOf Sequelize
*/
/**
......@@ -465,6 +469,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with factory
* @name afterDefine
* @memberOf Sequelize
*/
/**
......@@ -472,6 +477,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with config, options
* @name beforeInit
* @memberOf Sequelize
*/
/**
......@@ -479,6 +485,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with sequelize
* @name afterInit
* @memberOf Sequelize
*/
/**
......@@ -486,6 +493,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with config passed to connection
* @name beforeConnect
* @memberOf Sequelize
*/
/**
......@@ -493,6 +501,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options passed to Model.sync
* @name beforeSync
* @memberOf Sequelize
*/
/**
......@@ -500,6 +509,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options passed to Model.sync
* @name afterSync
* @memberOf Sequelize
*/
/**
......@@ -507,6 +517,7 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options passed to sequelize.sync
* @name beforeBulkSync
* @memberOf Sequelize
*/
/**
......@@ -514,4 +525,5 @@ exports.applyTo = applyTo;
* @param {String} name
* @param {Function} fn A callback function that is called with options passed to sequelize.sync
* @name afterBulkSync
* @memberOf Sequelize
*/
......@@ -14,6 +14,7 @@ const _ = require('lodash');
* @param {Instance} modelInstance The model instance.
* @param {Object} options A dict with options.
* @constructor
* @private
*/
class InstanceValidator {
......@@ -34,6 +35,7 @@ class InstanceValidator {
/**
* Exposes a reference to validator.js. This allows you to add custom validations using `validator.extend`
* @name validator
* @private
*/
this.validator = validator;
......@@ -42,10 +44,14 @@ class InstanceValidator {
*
* @type {Array} Will contain keys that correspond to attributes which will
* be Arrays of Errors.
* @private
*/
this.errors = [];
/** @type {boolean} Indicates if validations are in progress */
/**
* @type {boolean} Indicates if validations are in progress
* @private
*/
this.inProgress = false;
extendModelValidations(modelInstance);
......@@ -55,6 +61,7 @@ class InstanceValidator {
* The main entry point for the Validation module, invoke to start the dance.
*
* @return {Promise}
* @private
*/
_validate() {
if (this.inProgress) {
......@@ -79,6 +86,7 @@ class InstanceValidator {
* - On validation failure: Validation Failed Model Hooks
*
* @return {Promise}
* @private
*/
validate() {
if (this.options.hooks) {
......@@ -344,7 +352,10 @@ class InstanceValidator {
this.errors.push(error);
}
}
/** @define {string} The error key for arguments as passed by custom validators */
/**
* @define {string} The error key for arguments as passed by custom validators
* @private
*/
InstanceValidator.RAW_KEY_NAME = '__raw';
module.exports = InstanceValidator;
......
......@@ -40,6 +40,7 @@ class ModelManager {
* Iterate over Models in an order suitable for e.g. creating tables. Will
* take foreign key constraints into account so that dependencies are visited
* before dependents.
* @private
*/
forEachModel(iterator, options) {
const models = {};
......
......@@ -13,6 +13,7 @@ const QueryTypes = require('./query-types');
/**
* The interface that Sequelize uses to talk to all databases
* @class QueryInterface
* @private
*/
class QueryInterface {
constructor(sequelize) {
......@@ -765,6 +766,7 @@ class QueryInterface {
* Escape an identifier (e.g. a table or attribute name). If force is true,
* the identifier will be quoted even if the `quoteIdentifiers` option is
* false.
* @private
*/
quoteIdentifier(identifier, force) {
return this.QueryGenerator.quoteIdentifier(identifier, force);
......@@ -778,6 +780,7 @@ class QueryInterface {
* Split an identifier into .-separated tokens and quote each part.
* If force is true, the identifier will be quoted even if the
* `quoteIdentifiers` option is false.
* @private
*/
quoteIdentifiers(identifiers, force) {
return this.QueryGenerator.quoteIdentifiers(identifiers, force);
......@@ -785,6 +788,7 @@ class QueryInterface {
/**
* Escape a value (e.g. a string, number or date)
* @private
*/
escape(value) {
return this.QueryGenerator.escape(value);
......
'use strict';
/**
* @namespace QueryTypes
* @memberof Sequelize
*
*
* @property SELECT
* @property INSERT
* @property UPDATE
* @property BULKUPDATE
* @property BULKDELETE
* @property DELETE
* @property UPSERT
* @property VERSION
* @property SHOWTABLES
* @property SHOWINDEXES
* @property DESCRIBE
* @property RAW
* @property FOREIGNKEYS
*/
module.exports = {
SELECT: 'SELECT',
INSERT: 'INSERT',
......
......@@ -16,6 +16,8 @@ const uuid = require('node-uuid');
* @param {String} options.type=true Sets the type of the transaction.
* @param {String} options.isolationLevel=true Sets the isolation level of the transaction.
* @param {String} options.deferrable Sets the constraints to be deferred or immediately checked.
*
* @see {@link Sequelize.transaction}
*/
class Transaction {
constructor(sequelize, options) {
......@@ -170,20 +172,10 @@ class 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}, transaction => {
* return sequelize.transaction({type: Sequelize.Transaction.TYPES.EXCLUSIVE}, transaction => {
*
* // your transactions
*
......@@ -193,8 +185,9 @@ class Transaction {
* // do something with the err.
* });
* ```
*
* @property TYPES
* @property DEFERRED
* @property IMMEDIATE
* @property EXCLUSIVE
*/
Transaction.TYPES = {
DEFERRED: 'DEFERRED',
......@@ -206,21 +199,10 @@ Transaction.TYPES = {
* 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`.
*
* The possible isolations levels to use when starting a transaction:
*
* ```js
* {
* READ_UNCOMMITTED: "READ UNCOMMITTED",
* READ_COMMITTED: "READ COMMITTED",
* REPEATABLE_READ: "REPEATABLE READ",
* SERIALIZABLE: "SERIALIZABLE"
* }
* ```
*
* Pass in the desired level as the first argument:
*
* ```js
* return sequelize.transaction({isolationLevel: Sequelize.Transaction.SERIALIZABLE}, transaction => {
* return sequelize.transaction({isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE}, transaction => {
*
* // your transactions
*
......@@ -230,8 +212,10 @@ Transaction.TYPES = {
* // do something with the err.
* });
* ```
*
* @property ISOLATION_LEVELS
* @property READ_UNCOMMITTED
* @property READ_COMMITTED
* @property REPEATABLE_READ
* @property SERIALIZABLE
*/
Transaction.ISOLATION_LEVELS = {
READ_UNCOMMITTED: 'READ UNCOMMITTED',
......@@ -245,15 +229,6 @@ Transaction.ISOLATION_LEVELS = {
*
* ```js
* t1 // is a transaction
* t1.LOCK.UPDATE,
* t1.LOCK.SHARE,
* t1.LOCK.KEY_SHARE, // Postgres 9.3+ only
* t1.LOCK.NO_KEY_UPDATE // Postgres 9.3+ only
* ```
*
* Usage:
* ```js
* t1 // is a transaction
* Model.findAll({
* where: ...,
* transaction: t1,
......@@ -275,7 +250,10 @@ Transaction.ISOLATION_LEVELS = {
* ```
* UserModel will be locked but TaskModel won't!
*
* @property LOCK
* @property UPDATE
* @property SHARE
* @property KEY_SHARE Postgres 9.3+ only
* @property NO_KEY_UPDATE Postgres 9.3+ only
*/
Transaction.LOCK = Transaction.prototype.LOCK = {
UPDATE: 'UPDATE',
......
......@@ -358,6 +358,7 @@ exports.toDefaultValue = toDefaultValue;
*
* @param {*} value Any default value.
* @return {boolean} yes / no.
* @private
*/
function defaultValueSchemable(value) {
if (typeof value === 'undefined') { return false; }
......@@ -449,6 +450,7 @@ exports.removeTicks = removeTicks;
/**
* Utility functions for representing SQL functions, and columns that should be escaped.
* Please do not use these functions directly, use Sequelize.fn and Sequelize.col instead.
* @private
*/
class Fn {
constructor(fn, args) {
......
......@@ -3,7 +3,10 @@
const util = require('util');
const _ = require('lodash');
/** like util.inherits, but also copies over static properties */
/**
* like util.inherits, but also copies over static properties
* @private
*/
function inherits(constructor, superConstructor) {
util.inherits(constructor, superConstructor); // Instance (prototype) methods
_.extend(constructor, superConstructor); // Static methods
......
......@@ -5,6 +5,7 @@
* It require a `context` for which messages will be printed.
*
* @module logging
* @private
*/
/* jshint -W030 */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!