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

Commit d0e15380 by Jan Aagaard Meier

Update jsdocs for doclets

1 parent 37e6e63f
dir: lib
packageJson: package.json
articles:
- Getting started: docs/articles/getting-started.md
branches:
- master
- doclets
...@@ -34,7 +34,8 @@ const HasOne = require('./has-one'); ...@@ -34,7 +34,8 @@ 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()`. * 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
*/ */
class BelongsToMany extends Association { class BelongsToMany extends Association {
constructor(source, target, options) { constructor(source, target, options) {
...@@ -204,38 +205,46 @@ class BelongsToMany extends Association { ...@@ -204,38 +205,46 @@ class BelongsToMany extends Association {
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false * @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 * @param {String} [options.schema] Apply a schema on the related model
* @see {Model#findAll} for a full explanation of options * @see {Model#findAll} for a full explanation of options
* @return {Promise<Array<Instance>>} * @return {Promise<Array<Model>>}
* @method getAssociations * @method getAssociations
* @memberof Associations.BelongsToMany
* @instance
*/ */
get: 'get' + plural, 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. * 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] 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 * @param {Object} [options.validate] Run validation for the join model
* @return {Promise} * @return {Promise}
* @method setAssociations * @method setAssociations
* @memberof Associations.BelongsToMany
* @instance
*/ */
set: 'set' + plural, set: 'set' + plural,
/** /**
* Associate several persisted instances with this. * 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] 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. * @param {Object} [options.validate] Run validation for the join model.
* @return {Promise} * @return {Promise}
* @method addAssociations * @method addAssociations
* @memberof Associations.BelongsToMany
* @instance
*/ */
addMultiple: 'add' + plural, addMultiple: 'add' + plural,
/** /**
* Associate a persisted instance with this. * 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] 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. * @param {Object} [options.validate] Run validation for the join model.
* @return {Promise} * @return {Promise}
* @method addAssociation * @method addAssociation
* @memberof Associations.BelongsToMany
* @instance
*/ */
add: 'add' + singular, add: 'add' + singular,
/** /**
...@@ -245,42 +254,52 @@ class BelongsToMany extends Association { ...@@ -245,42 +254,52 @@ class BelongsToMany extends Association {
* @param {Object} [options] Options passed to create and add. Can also hold additional attributes for the join table * @param {Object} [options] Options passed to create and add. Can also hold additional attributes for the join table
* @return {Promise} * @return {Promise}
* @method createAssociation * @method createAssociation
* @memberof Associations.BelongsToMany
* @instance
*/ */
create: 'create' + singular, create: 'create' + singular,
/** /**
* Un-associate the instance. * 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` * @param {Object} [options] Options passed to `through.destroy`
* @return {Promise} * @return {Promise}
* @method removeAssociation * @method removeAssociation
* @memberof Associations.BelongsToMany
* @instance
*/ */
remove: 'remove' + singular, remove: 'remove' + singular,
/** /**
* Un-associate several instances. * 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` * @param {Object} [options] Options passed to `through.destroy`
* @return {Promise} * @return {Promise}
* @method removeAssociations * @method removeAssociations
* @memberof Associations.BelongsToMany
* @instance
*/ */
removeMultiple: 'remove' + plural, removeMultiple: 'remove' + plural,
/** /**
* Check if an instance is associated with this. * 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 * @param {Object} [options] Options passed to getAssociations
* @return {Promise} * @return {Promise}
* @method hasAssociation * @method hasAssociation
* @memberof Associations.BelongsToMany
* @instance
*/ */
hasSingle: 'has' + singular, hasSingle: 'has' + singular,
/** /**
* Check if all instances are associated with this. * 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 * @param {Object} [options] Options passed to getAssociations
* @return {Promise} * @return {Promise}
* @method hasAssociations * @method hasAssociations
* @memberof Associations.BelongsToMany
* @instance
*/ */
hasAll: 'has' + plural, hasAll: 'has' + plural,
/** /**
...@@ -289,8 +308,10 @@ class BelongsToMany extends Association { ...@@ -289,8 +308,10 @@ class BelongsToMany extends Association {
* @param {Object} [options] * @param {Object} [options]
* @param {Object} [options.where] An optional where clause to limit the associated models * @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|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 * @method countAssociations
* @memberof Associations.BelongsToMany
* @instance
*/ */
count: 'count' + plural count: 'count' + plural
}; };
......
...@@ -11,7 +11,8 @@ const Association = require('./base'); ...@@ -11,7 +11,8 @@ 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()`. * 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
*/ */
class BelongsTo extends Association { class BelongsTo extends Association {
constructor(source, target, options) { constructor(source, target, options) {
...@@ -78,19 +79,21 @@ class BelongsTo extends Association { ...@@ -78,19 +79,21 @@ class BelongsTo extends Association {
* @param {Object} [options] * @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|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 * @param {String} [options.schema] Apply a schema on the related model
* @see {Model#findOne} for a full explanation of options * @see {@link Model.findOne} for a full explanation of options
* @return {Promise<Instance>} * @return {Promise<Model>}
* @method getAssociation * @method getAssociation
* @memberof Associations.BelongsTo
*/ */
get: 'get' + singular, get: 'get' + singular,
/** /**
* Set the associated model. * 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 {Object} [options] Options passed to `this.save`
* @param {Boolean} [options.save=true] Skip saving this after setting the foreign key if false. * @param {Boolean} [options.save=true] Skip saving this after setting the foreign key if false.
* @return {Promise} * @return {Promise}
* @method setAssociation * @method setAssociation
* @memberof Associations.BelongsTo
*/ */
set: 'set' + singular, set: 'set' + singular,
/** /**
...@@ -101,6 +104,7 @@ class BelongsTo extends Association { ...@@ -101,6 +104,7 @@ class BelongsTo extends Association {
* @see {Model#create} for a full explanation of options * @see {Model#create} for a full explanation of options
* @return {Promise} * @return {Promise}
* @method createAssociation * @method createAssociation
* @memberof Associations.BelongsTo
*/ */
create: 'create' + singular create: 'create' + singular
}; };
......
...@@ -10,7 +10,8 @@ const Association = require('./base'); ...@@ -10,7 +10,8 @@ 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()`. * 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
*/ */
class HasMany extends Association { class HasMany extends Association {
constructor(source, target, options) { constructor(source, target, options) {
...@@ -98,38 +99,42 @@ class HasMany extends Association { ...@@ -98,38 +99,42 @@ class HasMany extends Association {
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false * @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 * @param {String} [options.schema] Apply a schema on the related model
* @see {Model#findAll} for a full explanation of options * @see {Model#findAll} for a full explanation of options
* @return {Promise<Array<Instance>>} * @return {Promise<Array<Model>>}
* @method getAssociations * @method getAssociations
* @memberof Associations.HasMany
*/ */
get: 'get' + plural, 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 * 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] Options passed to `target.findAll` and `update`.
* @param {Object} [options.validate] Run validation for the join model * @param {Object} [options.validate] Run validation for the join model
* @return {Promise} * @return {Promise}
* @method setAssociations * @method setAssociations
* @memberof Associations.HasMany
*/ */
set: 'set' + plural, set: 'set' + plural,
/** /**
* Associate several persisted instances with this. * 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] Options passed to `target.update`.
* @param {Object} [options.validate] Run validation for the join model. * @param {Object} [options.validate] Run validation for the join model.
* @return {Promise} * @return {Promise}
* @method addAssociations * @method addAssociations
* @memberof Associations.HasMany
*/ */
addMultiple: 'add' + plural, addMultiple: 'add' + plural,
/** /**
* Associate a persisted instance with this. * 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] Options passed to `target.update`.
* @param {Object} [options.validate] Run validation for the join model. * @param {Object} [options.validate] Run validation for the join model.
* @return {Promise} * @return {Promise}
* @method addAssociation * @method addAssociation
* @memberof Associations.HasMany
*/ */
add: 'add' + singular, add: 'add' + singular,
/** /**
...@@ -139,42 +144,47 @@ class HasMany extends Association { ...@@ -139,42 +144,47 @@ class HasMany extends Association {
* @param {Object} [options] Options passed to `target.create`. * @param {Object} [options] Options passed to `target.create`.
* @return {Promise} * @return {Promise}
* @method createAssociation * @method createAssociation
* @memberof Associations.HasMany
*/ */
create: 'create' + singular, create: 'create' + singular,
/** /**
* Un-associate the instance. * 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` * @param {Object} [options] Options passed to `target.update`
* @return {Promise} * @return {Promise}
* @method removeAssociation * @method removeAssociation
* @memberof Associations.HasMany
*/ */
remove: 'remove' + singular, remove: 'remove' + singular,
/** /**
* Un-associate several instances. * 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` * @param {Object} [options] Options passed to `through.destroy`
* @return {Promise} * @return {Promise}
* @method removeAssociations * @method removeAssociations
* @memberof Associations.HasMany
*/ */
removeMultiple: 'remove' + plural, removeMultiple: 'remove' + plural,
/** /**
* Check if an instance is associated with this. * 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 * @param {Object} [options] Options passed to getAssociations
* @return {Promise} * @return {Promise}
* @method hasAssociation * @method hasAssociation
* @memberof Associations.HasMany
*/ */
hasSingle: 'has' + singular, hasSingle: 'has' + singular,
/** /**
* Check if all instances are associated with this. * 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 * @param {Object} [options] Options passed to getAssociations
* @return {Promise} * @return {Promise}
* @method hasAssociations * @method hasAssociations
* @memberof Associations.HasMany
*/ */
hasAll: 'has' + plural, hasAll: 'has' + plural,
/** /**
...@@ -183,8 +193,9 @@ class HasMany extends Association { ...@@ -183,8 +193,9 @@ class HasMany extends Association {
* @param {Object} [options] * @param {Object} [options]
* @param {Object} [options.where] An optional where clause to limit the associated models * @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|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 * @method countAssociations
* @memberof Associations.HasMany
*/ */
count: 'count' + plural count: 'count' + plural
}; };
...@@ -333,7 +344,8 @@ class HasMany extends Association { ...@@ -333,7 +344,8 @@ class HasMany extends Association {
options = Utils.cloneDeep(options); options = Utils.cloneDeep(options);
options.attributes = [ options.attributes = [
[sequelize.fn('COUNT', sequelize.col(model.primaryKeyField)), 'count'] [sequelize.fn('COUNT', sequelize.col([model.name, model.primaryKeyAttribute].join('.'))), 'count']
]; ];
options.raw = true; options.raw = true;
options.plain = true; options.plain = true;
......
...@@ -11,7 +11,8 @@ const Association = require('./base'); ...@@ -11,7 +11,8 @@ 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()`. * In the API reference below, replace `Association` with the actual name of your association, e.g. for `User.hasOne(Project)` the getter will be `user.getProject()`.
* This is almost the same as `belongsTo` with one exception. The foreign key will be defined on the target model. * This is almost the same as `belongsTo` with one exception. The foreign key will be defined on the target model.
* *
* @mixin HasOne * @class HasOne
* @memberof Associations
*/ */
class HasOne extends Association { class HasOne extends Association {
constructor(srcModel, targetModel, options) { constructor(srcModel, targetModel, options) {
...@@ -76,8 +77,9 @@ class HasOne extends Association { ...@@ -76,8 +77,9 @@ class HasOne extends Association {
* @param {String|Boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false * @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 * @param {String} [options.schema] Apply a schema on the related model
* @see {Model#findOne} for a full explanation of options * @see {Model#findOne} for a full explanation of options
* @return {Promise<Instance>} * @return {Promise<Model>}
* @method getAssociation * @method getAssociation
* @memberof Associations.HasOne
*/ */
get: 'get' + singular, get: 'get' + singular,
/** /**
...@@ -87,6 +89,7 @@ class HasOne extends Association { ...@@ -87,6 +89,7 @@ class HasOne extends Association {
* @param {Object} [options] Options passed to getAssociation and `target.save` * @param {Object} [options] Options passed to getAssociation and `target.save`
* @return {Promise} * @return {Promise}
* @method setAssociation * @method setAssociation
* @memberof Associations.HasOne
*/ */
set: 'set' + singular, set: 'set' + singular,
/** /**
...@@ -97,6 +100,7 @@ class HasOne extends Association { ...@@ -97,6 +100,7 @@ class HasOne extends Association {
* @see {Model#create} for a full explanation of options * @see {Model#create} for a full explanation of options
* @return {Promise} * @return {Promise}
* @method createAssociation * @method createAssociation
* @memberof Associations.HasOne
*/ */
create: 'create' + singular create: 'create' + singular
}; };
......
...@@ -83,7 +83,7 @@ const BelongsTo = require('./belongs-to'); ...@@ -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. * 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 * @name Associations
*/ */
const Mixin = { const Mixin = {
...@@ -101,6 +101,8 @@ 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.onDelete='SET&nbsp;NULL|CASCADE'] SET NULL if foreignKey allows nulls, CASCADE if otherwise
* @param {string} [options.onUpdate='CASCADE'] * @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key. * @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 hasMany(target, options) { // testhint options:none
if (!target.prototype || !(target.prototype instanceof this.sequelize.Model)) { if (!target.prototype || !(target.prototype instanceof this.sequelize.Model)) {
...@@ -180,6 +182,8 @@ const Mixin = { ...@@ -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.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 {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key. * @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 belongsToMany(targetModel, options) { // testhint options:none
if (!targetModel.prototype || !(targetModel.prototype instanceof this.sequelize.Model)) { if (!targetModel.prototype || !(targetModel.prototype instanceof this.sequelize.Model)) {
...@@ -265,6 +269,8 @@ function singleLinked(Type) { ...@@ -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.onDelete='SET&nbsp;NULL|CASCADE'] SET NULL if foreignKey allows nulls, CASCADE if otherwise
* @param {string} [options.onUpdate='CASCADE'] * @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key. * @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); Mixin.hasOne = singleLinked(HasOne);
...@@ -283,6 +289,8 @@ 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.onDelete='SET&nbsp;NULL|NO&nbsp;ACTION'] SET NULL if foreignKey allows nulls, NO ACTION if otherwise
* @param {string} [options.onUpdate='CASCADE'] * @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key. * @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); Mixin.belongsTo = singleLinked(BelongsTo);
......
...@@ -53,7 +53,7 @@ const moment = require('moment'); ...@@ -53,7 +53,7 @@ const moment = require('moment');
* }) * })
* ``` * ```
* *
* @class DataTypes * @namespace DataTypes
*/ */
function ABSTRACT() {} function ABSTRACT() {}
...@@ -82,9 +82,8 @@ ABSTRACT.prototype.stringify = function stringify(value, options) { ...@@ -82,9 +82,8 @@ ABSTRACT.prototype.stringify = function stringify(value, options) {
/** /**
* A variable length string. Default length 255 * A variable length string. Default length 255
* *
* Available properties: `BINARY` * @property BINARY
* * @memberof DataTypes
* @property STRING
*/ */
function STRING(length, binary) { function STRING(length, binary) {
const options = typeof length === 'object' && length || {length, binary}; const options = typeof length === 'object' && length || {length, binary};
...@@ -124,7 +123,7 @@ Object.defineProperty(STRING.prototype, 'BINARY', { ...@@ -124,7 +123,7 @@ Object.defineProperty(STRING.prototype, 'BINARY', {
* *
* Available properties: `BINARY` * Available properties: `BINARY`
* *
* @property CHAR * @memberof DataTypes
*/ */
function CHAR(length, binary) { function CHAR(length, binary) {
const options = typeof length === 'object' && length || {length, binary}; const options = typeof length === 'object' && length || {length, binary};
...@@ -141,7 +140,8 @@ CHAR.prototype.toSql = function toSql() { ...@@ -141,7 +140,8 @@ CHAR.prototype.toSql = function toSql() {
/** /**
* An (un)limited length text column. Available lengths: `tiny`, `medium`, `long` * An (un)limited length text column. Available lengths: `tiny`, `medium`, `long`
* @property TEXT *
* @memberof DataTypes
*/ */
function TEXT(length) { function TEXT(length) {
const options = typeof length === 'object' && length || {length}; const options = typeof length === 'object' && length || {length};
...@@ -228,9 +228,9 @@ Object.defineProperty(NUMBER.prototype, 'ZEROFILL', { ...@@ -228,9 +228,9 @@ Object.defineProperty(NUMBER.prototype, 'ZEROFILL', {
/** /**
* A 32 bit integer. * A 32 bit integer.
* *
* Available properties: `UNSIGNED`, `ZEROFILL` * @property UNSIGNED
* * @property ZEROFILL
* @property INTEGER * @memberof DataTypes
*/ */
function INTEGER(length) { function INTEGER(length) {
const options = typeof length === 'object' && length || {length}; const options = typeof length === 'object' && length || {length};
...@@ -253,9 +253,9 @@ INTEGER.prototype.validate = function validate(value) { ...@@ -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). * 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 UNSIGNED
* * @property ZEROFILL
* @property BIGINT * @memberof DataTypes
*/ */
function BIGINT(length) { function BIGINT(length) {
...@@ -277,9 +277,9 @@ BIGINT.prototype.validate = function validate(value) { ...@@ -277,9 +277,9 @@ BIGINT.prototype.validate = function validate(value) {
/** /**
* Floating point number (4-byte precision). Accepts one or two arguments for precision * Floating point number (4-byte precision). Accepts one or two arguments for precision
* *
* Available properties: `UNSIGNED`, `ZEROFILL` * @property UNSIGNED
* * @property ZEROFILL
* @property FLOAT * @memberof DataTypes
*/ */
function FLOAT(length, decimals) { function FLOAT(length, decimals) {
const options = typeof length === 'object' && length || {length, decimals}; const options = typeof length === 'object' && length || {length, decimals};
...@@ -300,9 +300,9 @@ FLOAT.prototype.validate = function validate(value) { ...@@ -300,9 +300,9 @@ FLOAT.prototype.validate = function validate(value) {
/** /**
* Floating point number (4-byte precision). Accepts one or two arguments for precision * Floating point number (4-byte precision). Accepts one or two arguments for precision
* *
* Available properties: `UNSIGNED`, `ZEROFILL` * @property UNSIGNED
* * @property ZEROFILL
* @property REAL * @memberof DataTypes
*/ */
function REAL(length, decimals) { function REAL(length, decimals) {
const options = typeof length === 'object' && length || {length, decimals}; const options = typeof length === 'object' && length || {length, decimals};
...@@ -316,9 +316,9 @@ REAL.prototype.key = REAL.key = 'REAL'; ...@@ -316,9 +316,9 @@ REAL.prototype.key = REAL.key = 'REAL';
/** /**
* Floating point number (8-byte precision). Accepts one or two arguments for precision * Floating point number (8-byte precision). Accepts one or two arguments for precision
* *
* Available properties: `UNSIGNED`, `ZEROFILL` * @property UNSIGNED
* * @property ZEROFILL
* @property DOUBLE * @memberof DataTypes
*/ */
function DOUBLE(length, decimals) { function DOUBLE(length, decimals) {
const options = typeof length === 'object' && length || {length, decimals}; const options = typeof length === 'object' && length || {length, decimals};
...@@ -332,9 +332,9 @@ DOUBLE.prototype.key = DOUBLE.key = 'DOUBLE PRECISION'; ...@@ -332,9 +332,9 @@ DOUBLE.prototype.key = DOUBLE.key = 'DOUBLE PRECISION';
/** /**
* Decimal number. Accepts one or two arguments for precision * Decimal number. Accepts one or two arguments for precision
* *
* Available properties: `UNSIGNED`, `ZEROFILL` * @property UNSIGNED
* * @property ZEROFILL
* @property DECIMAL * @memberof DataTypes
*/ */
function DECIMAL(precision, scale) { function DECIMAL(precision, scale) {
const options = typeof precision === 'object' && precision || {precision, scale}; const options = typeof precision === 'object' && precision || {precision, scale};
...@@ -375,7 +375,8 @@ for (const floating of [FLOAT, DOUBLE, REAL]) { ...@@ -375,7 +375,8 @@ for (const floating of [FLOAT, DOUBLE, REAL]) {
/** /**
* A boolean / tinyint column, depending on dialect * A boolean / tinyint column, depending on dialect
* @property BOOLEAN *
* @memberof DataTypes
*/ */
function BOOLEAN() { function BOOLEAN() {
if (!(this instanceof BOOLEAN)) return new BOOLEAN(); if (!(this instanceof BOOLEAN)) return new BOOLEAN();
...@@ -396,7 +397,8 @@ BOOLEAN.prototype.validate = function validate(value) { ...@@ -396,7 +397,8 @@ BOOLEAN.prototype.validate = function validate(value) {
/** /**
* A time column * A time column
* @property TIME *
* @memberof DataTypes
*/ */
function TIME() { function TIME() {
...@@ -411,7 +413,8 @@ TIME.prototype.toSql = function toSql() { ...@@ -411,7 +413,8 @@ TIME.prototype.toSql = function toSql() {
/** /**
* A datetime column * A datetime column
* @property DATE *
* @memberof DataTypes
*/ */
function DATE(length) { function DATE(length) {
const options = typeof length === 'object' && length || {length}; const options = typeof length === 'object' && length || {length};
...@@ -458,7 +461,8 @@ DATE.prototype.$stringify = function $stringify(date, options) { ...@@ -458,7 +461,8 @@ DATE.prototype.$stringify = function $stringify(date, options) {
/** /**
* A date only column * A date only column
* @property DATEONLY *
* @memberof DataTypes
*/ */
function DATEONLY() { function DATEONLY() {
...@@ -473,7 +477,8 @@ DATEONLY.prototype.toSql = function() { ...@@ -473,7 +477,8 @@ DATEONLY.prototype.toSql = function() {
/** /**
* A key / value column. Only available in postgres. * A key / value column. Only available in postgres.
* @property HSTORE *
* @memberof DataTypes
*/ */
function HSTORE() { function HSTORE() {
...@@ -492,7 +497,9 @@ HSTORE.prototype.validate = function validate(value) { ...@@ -492,7 +497,9 @@ HSTORE.prototype.validate = function validate(value) {
/** /**
* A JSON string column. Only available in postgres. * A JSON string column. Only available in postgres.
* @property JSON *
* @function JSON
* @memberof DataTypes
*/ */
function JSONTYPE() { function JSONTYPE() {
if (!(this instanceof JSONTYPE)) return new JSONTYPE(); if (!(this instanceof JSONTYPE)) return new JSONTYPE();
...@@ -510,7 +517,8 @@ JSONTYPE.prototype.$stringify = function $stringify(value, options) { ...@@ -510,7 +517,8 @@ JSONTYPE.prototype.$stringify = function $stringify(value, options) {
/** /**
* A pre-processed JSON data column. Only available in postgres. * A pre-processed JSON data column. Only available in postgres.
* @property JSONB *
* @memberof DataTypes
*/ */
function JSONB() { function JSONB() {
if (!(this instanceof JSONB)) return new JSONB(); if (!(this instanceof JSONB)) return new JSONB();
...@@ -522,7 +530,8 @@ JSONB.prototype.key = JSONB.key = 'JSONB'; ...@@ -522,7 +530,8 @@ JSONB.prototype.key = JSONB.key = 'JSONB';
/** /**
* A default value of the current timestamp * A default value of the current timestamp
* @property NOW *
* @memberof DataTypes
*/ */
function NOW() { function NOW() {
if (!(this instanceof NOW)) return new NOW(); if (!(this instanceof NOW)) return new NOW();
...@@ -534,7 +543,7 @@ NOW.prototype.key = NOW.key = 'NOW'; ...@@ -534,7 +543,7 @@ NOW.prototype.key = NOW.key = 'NOW';
/** /**
* Binary storage. Available lengths: `tiny`, `medium`, `long` * Binary storage. Available lengths: `tiny`, `medium`, `long`
* *
* @property BLOB * @memberof DataTypes
*/ */
function BLOB(length) { function BLOB(length) {
const options = typeof length === 'object' && length || {length}; const options = typeof length === 'object' && length || {length};
...@@ -587,7 +596,8 @@ BLOB.prototype.$hexify = function $hexify(hex) { ...@@ -587,7 +596,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). * Range types are data types representing a range of values of some element type (called the range's subtype).
* Only available in postgres. * Only available in postgres.
* See {@link http://www.postgresql.org/docs/9.4/static/rangetypes.html|Postgres documentation} for more details * See {@link http://www.postgresql.org/docs/9.4/static/rangetypes.html|Postgres documentation} for more details
* @property RANGE *
* @memberof DataTypes
*/ */
function RANGE(subtype) { function RANGE(subtype) {
...@@ -650,7 +660,8 @@ RANGE.prototype.validate = function validate(value) { ...@@ -650,7 +660,8 @@ RANGE.prototype.validate = function validate(value) {
/** /**
* A column storing a unique universal identifier. Use with `UUIDV1` or `UUIDV4` for default values. * A column storing a unique universal identifier. Use with `UUIDV1` or `UUIDV4` for default values.
* @property UUID *
* @memberof DataTypes
*/ */
function UUID() { function UUID() {
if (!(this instanceof UUID)) return new UUID(); if (!(this instanceof UUID)) return new UUID();
...@@ -668,7 +679,8 @@ UUID.prototype.validate = function validate(value, options) { ...@@ -668,7 +679,8 @@ UUID.prototype.validate = function validate(value, options) {
/** /**
* A default unique universal identifier generated following the UUID v1 standard * A default unique universal identifier generated following the UUID v1 standard
* @property UUIDV1 *
* @memberof DataTypes
*/ */
function UUIDV1() { function UUIDV1() {
...@@ -687,7 +699,8 @@ UUIDV1.prototype.validate = function validate(value, options) { ...@@ -687,7 +699,8 @@ UUIDV1.prototype.validate = function validate(value, options) {
/** /**
* A default unique universal identifier generated following the UUID v4 standard * A default unique universal identifier generated following the UUID v4 standard
* @property UUIDV4 *
* @memberof DataTypes
*/ */
function UUIDV4() { function UUIDV4() {
...@@ -743,8 +756,7 @@ UUIDV4.prototype.validate = function validate(value, options) { ...@@ -743,8 +756,7 @@ UUIDV4.prototype.validate = function validate(value, options) {
* } * }
* ``` * ```
* *
* @property VIRTUAL * @memberof DataTypes
* @alias NONE
*/ */
function VIRTUAL(ReturnType, fields) { function VIRTUAL(ReturnType, fields) {
if (!(this instanceof VIRTUAL)) return new VIRTUAL(ReturnType, fields); if (!(this instanceof VIRTUAL)) return new VIRTUAL(ReturnType, fields);
...@@ -760,7 +772,7 @@ VIRTUAL.prototype.key = VIRTUAL.key = 'VIRTUAL'; ...@@ -760,7 +772,7 @@ VIRTUAL.prototype.key = VIRTUAL.key = 'VIRTUAL';
/** /**
* An enumeration. `DataTypes.ENUM('value', 'another value')`. * An enumeration. `DataTypes.ENUM('value', 'another value')`.
* *
* @property ENUM * @memberof DataTypes
*/ */
function ENUM(value) { function ENUM(value) {
const options = typeof value === 'object' && !Array.isArray(value) && value || { const options = typeof value === 'object' && !Array.isArray(value) && value || {
...@@ -785,7 +797,8 @@ ENUM.prototype.validate = function validate(value) { ...@@ -785,7 +797,8 @@ ENUM.prototype.validate = function validate(value) {
/** /**
* An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in postgres. * An array of `type`, e.g. `DataTypes.ARRAY(DataTypes.DECIMAL)`. Only available in postgres.
* @property ARRAY *
* @memberof DataTypes
*/ */
function ARRAY(type) { function ARRAY(type) {
const options = _.isPlainObject(type) ? type : {type}; const options = _.isPlainObject(type) ? type : {type};
...@@ -865,7 +878,7 @@ const helpers = { ...@@ -865,7 +878,7 @@ const helpers = {
* }); * });
* ``` * ```
* *
* @property GEOMETRY * @memberof DataTypes
*/ */
function GEOMETRY(type, srid) { function GEOMETRY(type, srid) {
...@@ -888,7 +901,8 @@ GEOMETRY.prototype.$stringify = function $stringify(value) { ...@@ -888,7 +901,8 @@ GEOMETRY.prototype.$stringify = function $stringify(value) {
/** /**
* A geography datatype represents two dimensional spacial objects in an elliptic coord system. * A geography datatype represents two dimensional spacial objects in an elliptic coord system.
* @property GEOGRAPHY *
* @memberof DataTypes
*/ */
function GEOGRAPHY(type, srid) { function GEOGRAPHY(type, srid) {
......
...@@ -34,7 +34,12 @@ var util = require('util'); ...@@ -34,7 +34,12 @@ 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.
*/ */
var Deferrable = module.exports = { var Deferrable = module.exports = {
INITIALLY_DEFERRED: INITIALLY_DEFERRED, INITIALLY_DEFERRED: INITIALLY_DEFERRED,
...@@ -50,12 +55,6 @@ ABSTRACT.prototype.toString = function () { ...@@ -50,12 +55,6 @@ ABSTRACT.prototype.toString = function () {
return this.toSql.apply(this, arguments); return this.toSql.apply(this, arguments);
}; };
/**
* A property that will defer constraints checks to the end of transactions.
*
* @property INITIALLY_DEFERRED
*/
function INITIALLY_DEFERRED () { function INITIALLY_DEFERRED () {
if (!(this instanceof INITIALLY_DEFERRED)) { if (!(this instanceof INITIALLY_DEFERRED)) {
return new INITIALLY_DEFERRED(); return new INITIALLY_DEFERRED();
...@@ -67,12 +66,6 @@ INITIALLY_DEFERRED.prototype.toSql = function () { ...@@ -67,12 +66,6 @@ INITIALLY_DEFERRED.prototype.toSql = function () {
return 'DEFERRABLE INITIALLY DEFERRED'; return 'DEFERRABLE INITIALLY DEFERRED';
}; };
/**
* A property that will trigger the constraint checks immediately
*
* @property INITIALLY_IMMEDIATE
*/
function INITIALLY_IMMEDIATE () { function INITIALLY_IMMEDIATE () {
if (!(this instanceof INITIALLY_IMMEDIATE)) { if (!(this instanceof INITIALLY_IMMEDIATE)) {
return new INITIALLY_IMMEDIATE(); return new INITIALLY_IMMEDIATE();
...@@ -84,14 +77,6 @@ INITIALLY_IMMEDIATE.prototype.toSql = function () { ...@@ -84,14 +77,6 @@ INITIALLY_IMMEDIATE.prototype.toSql = function () {
return 'DEFERRABLE INITIALLY IMMEDIATE'; 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 () { function NOT () {
if (!(this instanceof NOT)) { if (!(this instanceof NOT)) {
return new NOT(); return new NOT();
...@@ -109,7 +94,7 @@ NOT.prototype.toSql = function () { ...@@ -109,7 +94,7 @@ NOT.prototype.toSql = function () {
* transaction which sets the constraints to deferred. * transaction which sets the constraints to deferred.
* *
* @param {Array} constraints An array of constraint names. Will defer all constraints by default. * @param {Array} constraints An array of constraint names. Will defer all constraints by default.
* @property SET_DEFERRED * @memberof Sequelize.Deferrable
*/ */
function SET_DEFERRED (constraints) { function SET_DEFERRED (constraints) {
if (!(this instanceof SET_DEFERRED)) { if (!(this instanceof SET_DEFERRED)) {
...@@ -130,7 +115,7 @@ SET_DEFERRED.prototype.toSql = function (queryGenerator) { ...@@ -130,7 +115,7 @@ SET_DEFERRED.prototype.toSql = function (queryGenerator) {
* transaction which sets the constraints to immediately. * transaction which sets the constraints to immediately.
* *
* @param {Array} constraints An array of constraint names. Will defer all constraints by default. * @param {Array} constraints An array of constraint names. Will defer all constraints by default.
* @property SET_IMMEDIATE * @memberof Sequelize.Deferrable
*/ */
function SET_IMMEDIATE (constraints) { function SET_IMMEDIATE (constraints) {
if (!(this instanceof SET_IMMEDIATE)) { if (!(this instanceof SET_IMMEDIATE)) {
......
...@@ -19,6 +19,7 @@ class AbstractQuery { ...@@ -19,6 +19,7 @@ class AbstractQuery {
* Options * Options
* skipUnescape: bool, skip unescaping $$ * skipUnescape: bool, skip unescaping $$
* skipValueReplace: bool, do not replace (but do unescape $$). Check correct syntax and if all values are available * 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) { static formatBindParameters(sql, values, dialect, replacementFunc, options) {
if (!values) { if (!values) {
...@@ -94,7 +95,7 @@ class AbstractQuery { ...@@ -94,7 +95,7 @@ class AbstractQuery {
* query.run('SELECT 1') * query.run('SELECT 1')
* *
* @param {String} sql - The SQL query which should be executed. * @param {String} sql - The SQL query which should be executed.
* @api public * @private
*/ */
run() { run() {
throw new Error('The run method wasn\'t overwritten!'); throw new Error('The run method wasn\'t overwritten!');
...@@ -104,6 +105,7 @@ class AbstractQuery { ...@@ -104,6 +105,7 @@ class AbstractQuery {
* Check the logging option of the instance and print deprecation warnings. * Check the logging option of the instance and print deprecation warnings.
* *
* @return {void} * @return {void}
* @private
*/ */
checkLoggingOption() { checkLoggingOption() {
if (this.options.logging === true) { if (this.options.logging === true) {
...@@ -116,6 +118,7 @@ class AbstractQuery { ...@@ -116,6 +118,7 @@ class AbstractQuery {
* Get the attributes of an insert query, which contains the just inserted id. * Get the attributes of an insert query, which contains the just inserted id.
* *
* @return {String} The field name. * @return {String} The field name.
* @private
*/ */
getInsertIdField() { getInsertIdField() {
return 'insertId'; return 'insertId';
...@@ -127,6 +130,7 @@ class AbstractQuery { ...@@ -127,6 +130,7 @@ class AbstractQuery {
* *
* @param {String} attribute An attribute of a SQL query. (?) * @param {String} attribute An attribute of a SQL query. (?)
* @return {String} The found tableName / alias. * @return {String} The found tableName / alias.
* @private
*/ */
findTableNameInAttribute(attribute) { findTableNameInAttribute(attribute) {
if (!this.options.include) { if (!this.options.include) {
...@@ -353,6 +357,7 @@ class AbstractQuery { ...@@ -353,6 +357,7 @@ class AbstractQuery {
* ] * ]
* } * }
* ] * ]
* @private
*/ */
static $groupJoinData(rows, includeOptions, options) { static $groupJoinData(rows, includeOptions, options) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
@class QueryInterface @class QueryInterface
@static @static
@private
*/ */
/** /**
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
@param {String} attributeName The name of the attribute that we want to remove. @param {String} attributeName The name of the attribute that we want to remove.
@param {Object} options @param {Object} options
@param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries @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 removeColumn = function (tableName, attributeName, options) {
var self = this; var self = this;
......
...@@ -128,6 +128,7 @@ class Query extends AbstractQuery { ...@@ -128,6 +128,7 @@ class Query extends AbstractQuery {
* ]) * ])
* *
* @param {Array} data - The result of the query execution. * @param {Array} data - The result of the query execution.
* @private
*/ */
formatResults(data) { formatResults(data) {
let result = this.instance; let result = this.instance;
......
...@@ -299,6 +299,7 @@ const QueryGenerator = { ...@@ -299,6 +299,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table. * @param {String} tableName The name of the table.
* @param {String} schemaName The name of the schema. * @param {String} schemaName The name of the schema.
* @return {String} The generated sql query. * @return {String} The generated sql query.
* @private
*/ */
getForeignKeysQuery(tableName, schemaName) { getForeignKeysQuery(tableName, schemaName) {
return "SELECT CONSTRAINT_NAME as constraint_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME = '" + tableName + /* jshint ignore: line */ return "SELECT CONSTRAINT_NAME as constraint_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME = '" + tableName + /* jshint ignore: line */
...@@ -311,6 +312,7 @@ const QueryGenerator = { ...@@ -311,6 +312,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table. * @param {String} tableName The name of the table.
* @param {String} columnName The name of the column. * @param {String} columnName The name of the column.
* @return {String} The generated sql query. * @return {String} The generated sql query.
* @private
*/ */
getForeignKeyQuery(table, columnName) { getForeignKeyQuery(table, columnName) {
let tableName = table.tableName || table; let tableName = table.tableName || table;
...@@ -332,6 +334,7 @@ const QueryGenerator = { ...@@ -332,6 +334,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table. * @param {String} tableName The name of the table.
* @param {String} foreignKey The name of the foreign key constraint. * @param {String} foreignKey The name of the foreign key constraint.
* @return {String} The generated sql query. * @return {String} The generated sql query.
* @private
*/ */
dropForeignKeyQuery(tableName, foreignKey) { dropForeignKeyQuery(tableName, foreignKey) {
return 'ALTER TABLE ' + this.quoteTable(tableName) + ' DROP FOREIGN KEY ' + this.quoteIdentifier(foreignKey) + ';'; return 'ALTER TABLE ' + this.quoteTable(tableName) + ' DROP FOREIGN KEY ' + this.quoteIdentifier(foreignKey) + ';';
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
@class QueryInterface @class QueryInterface
@static @static
@private
*/ */
const _ = require('lodash'); const _ = require('lodash');
...@@ -18,6 +19,7 @@ const _ = require('lodash'); ...@@ -18,6 +19,7 @@ const _ = require('lodash');
@param {String} tableName The name of the table. @param {String} tableName The name of the table.
@param {String} columnName The name of the attribute that we want to remove. @param {String} columnName The name of the attribute that we want to remove.
@param {Object} options @param {Object} options
@private
*/ */
function removeColumn(tableName, columnName, options) { function removeColumn(tableName, columnName, options) {
options = options || {}; options = options || {};
......
...@@ -85,6 +85,7 @@ class Query extends AbstractQuery { ...@@ -85,6 +85,7 @@ class Query extends AbstractQuery {
* ]) * ])
* *
* @param {Array} data - The result of the query execution. * @param {Array} data - The result of the query execution.
* @private
*/ */
formatResults(data) { formatResults(data) {
let result = this.instance; let result = this.instance;
......
...@@ -763,6 +763,7 @@ const QueryGenerator = { ...@@ -763,6 +763,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table. * @param {String} tableName The name of the table.
* @param {String} schemaName The name of the schema. * @param {String} schemaName The name of the schema.
* @return {String} The generated sql query. * @return {String} The generated sql query.
* @private
*/ */
getForeignKeysQuery(tableName, schemaName) { 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 ' + return 'SELECT conname as constraint_name, pg_catalog.pg_get_constraintdef(r.oid, true) as condef FROM pg_catalog.pg_constraint r ' +
...@@ -775,6 +776,7 @@ const QueryGenerator = { ...@@ -775,6 +776,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table. * @param {String} tableName The name of the table.
* @param {String} foreignKey The name of the foreign key constraint. * @param {String} foreignKey The name of the foreign key constraint.
* @return {String} The generated sql query. * @return {String} The generated sql query.
* @private
*/ */
dropForeignKeyQuery(tableName, foreignKey) { dropForeignKeyQuery(tableName, foreignKey) {
return 'ALTER TABLE ' + this.quoteTable(tableName) + ' DROP CONSTRAINT ' + this.quoteIdentifier(foreignKey) + ';'; return 'ALTER TABLE ' + this.quoteTable(tableName) + ' DROP CONSTRAINT ' + this.quoteIdentifier(foreignKey) + ';';
......
...@@ -26,6 +26,7 @@ class Query extends AbstractQuery { ...@@ -26,6 +26,7 @@ class Query extends AbstractQuery {
/** /**
* rewrite query with parameters * rewrite query with parameters
* @private
*/ */
static formatBindParameters(sql, values, dialect) { static formatBindParameters(sql, values, dialect) {
let bindParam = []; let bindParam = [];
......
...@@ -343,6 +343,7 @@ const QueryGenerator = { ...@@ -343,6 +343,7 @@ const QueryGenerator = {
* @param {String} tableName The name of the table. * @param {String} tableName The name of the table.
* @param {String} schemaName The name of the schema. * @param {String} schemaName The name of the schema.
* @return {String} The generated sql query. * @return {String} The generated sql query.
* @private
*/ */
getForeignKeysQuery(tableName, schemaName) { getForeignKeysQuery(tableName, schemaName) {
return `PRAGMA foreign_key_list(${tableName})`; return `PRAGMA foreign_key_list(${tableName})`;
......
...@@ -8,6 +8,7 @@ const Promise = require('../../promise'); ...@@ -8,6 +8,7 @@ const Promise = require('../../promise');
@class QueryInterface @class QueryInterface
@static @static
@private
*/ */
/** /**
...@@ -24,6 +25,7 @@ const Promise = require('../../promise'); ...@@ -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 @param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@since 1.6.0 @since 1.6.0
@private
*/ */
function removeColumn(tableName, attributeName, options) { function removeColumn(tableName, attributeName, options) {
options = options || {}; options = options || {};
...@@ -54,6 +56,7 @@ exports.removeColumn = removeColumn; ...@@ -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 @param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@since 1.6.0 @since 1.6.0
@private
*/ */
function changeColumn(tableName, attributes, options) { function changeColumn(tableName, attributes, options) {
const attributeName = Object.keys(attributes)[0]; const attributeName = Object.keys(attributes)[0];
...@@ -86,6 +89,7 @@ exports.changeColumn = changeColumn; ...@@ -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 @param {Boolean|Function} [options.logging] A function that logs the sql queries, or false for explicitly not logging these queries
@since 1.6.0 @since 1.6.0
@private
*/ */
function renameColumn(tableName, attrNameBefore, attrNameAfter, options) { function renameColumn(tableName, attrNameBefore, attrNameAfter, options) {
options = options || {}; options = options || {};
......
...@@ -32,6 +32,7 @@ class Query extends AbstractQuery { ...@@ -32,6 +32,7 @@ class Query extends AbstractQuery {
/** /**
* rewrite query with parameters * rewrite query with parameters
* @private
*/ */
static formatBindParameters(sql, values, dialect) { static formatBindParameters(sql, values, dialect) {
let bindParam; let bindParam;
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
* All sequelize errors inherit from the base JS error object. * All sequelize errors inherit from the base JS error object.
* *
* @fileOverview The Error Objects produced by Sequelize. * @fileOverview The Error Objects produced by Sequelize.
* @class Errors * @namespace Errors
*/ */
/** /**
* The Base Error all Sequelize Errors inherit from. * The Base Error all Sequelize Errors inherit from.
* *
* @constructor
* @alias Error * @alias Error
* @memberof Errors
*/ */
class BaseError extends Error { class BaseError extends Error {
constructor(message) { constructor(message) {
...@@ -30,7 +30,7 @@ exports.BaseError = BaseError; ...@@ -30,7 +30,7 @@ exports.BaseError = BaseError;
* @param {string} message Error message * @param {string} message Error message
* *
* @extends BaseError * @extends BaseError
* @constructor * @memberof Errors
*/ */
class SequelizeScopeError extends BaseError { class SequelizeScopeError extends BaseError {
constructor(parent) { constructor(parent) {
...@@ -48,17 +48,15 @@ exports.SequelizeScopeError = SequelizeScopeError; ...@@ -48,17 +48,15 @@ exports.SequelizeScopeError = SequelizeScopeError;
* @param {Array} [errors] Array of ValidationErrorItem objects describing the validation errors * @param {Array} [errors] Array of ValidationErrorItem objects describing the validation errors
* *
* @extends BaseError * @extends BaseError
* @constructor * @memberof Errors
*
* @property errors An array of ValidationErrorItems
*/ */
class ValidationError extends BaseError { class ValidationError extends BaseError {
constructor(message, errors) { constructor(message, errors) {
super(message); super(message);
this.name = 'SequelizeValidationError'; this.name = 'SequelizeValidationError';
this.message = 'Validation Error'; this.message = 'Validation Error';
/**
* An array of ValidationErrorItems
* @member errors
*/
this.errors = errors || []; this.errors = errors || [];
// Use provided error message if available... // Use provided error message if available...
...@@ -91,43 +89,23 @@ exports.ValidationError = ValidationError; ...@@ -91,43 +89,23 @@ exports.ValidationError = ValidationError;
/** /**
* A base class for all database related errors. * A base class for all database related errors.
* @extends BaseError * @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 { class DatabaseError extends BaseError {
constructor(parent) { constructor(parent) {
super(parent.message); super(parent.message);
this.name = 'SequelizeDatabaseError'; this.name = 'SequelizeDatabaseError';
/**
* The database specific error which triggered this one
* @member parent
*/
this.parent = parent; this.parent = parent;
this.original = parent; this.original = parent;
/**
* The SQL that triggered the error
* @member sql
*/
this.sql = parent.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; exports.DatabaseError = DatabaseError;
...@@ -135,7 +113,7 @@ exports.DatabaseError = DatabaseError; ...@@ -135,7 +113,7 @@ exports.DatabaseError = DatabaseError;
/** /**
* Thrown when a database query times out because of a deadlock * Thrown when a database query times out because of a deadlock
* @extends DatabaseError * @extends DatabaseError
* @constructor * @memberof Errors
*/ */
class TimeoutError extends BaseError { class TimeoutError extends BaseError {
constructor(parent) { constructor(parent) {
...@@ -148,7 +126,7 @@ exports.TimeoutError = TimeoutError; ...@@ -148,7 +126,7 @@ exports.TimeoutError = TimeoutError;
/** /**
* Thrown when a unique constraint is violated in the database * Thrown when a unique constraint is violated in the database
* @extends DatabaseError * @extends DatabaseError
* @constructor * @memberof Errors
*/ */
class UniqueConstraintError extends ValidationError { class UniqueConstraintError extends ValidationError {
constructor(options) { constructor(options) {
...@@ -169,7 +147,7 @@ exports.UniqueConstraintError = UniqueConstraintError; ...@@ -169,7 +147,7 @@ exports.UniqueConstraintError = UniqueConstraintError;
/** /**
* Thrown when a foreign key constraint is violated in the database * Thrown when a foreign key constraint is violated in the database
* @extends DatabaseError * @extends DatabaseError
* @constructor * @memberof Errors
*/ */
class ForeignKeyConstraintError extends DatabaseError { class ForeignKeyConstraintError extends DatabaseError {
constructor(options) { constructor(options) {
...@@ -191,7 +169,7 @@ exports.ForeignKeyConstraintError = ForeignKeyConstraintError; ...@@ -191,7 +169,7 @@ exports.ForeignKeyConstraintError = ForeignKeyConstraintError;
/** /**
* Thrown when an exclusion constraint is violated in the database * Thrown when an exclusion constraint is violated in the database
* @extends DatabaseError * @extends DatabaseError
* @constructor * @memberof Errors
*/ */
class ExclusionConstraintError extends DatabaseError { class ExclusionConstraintError extends DatabaseError {
constructor(options) { constructor(options) {
...@@ -217,7 +195,7 @@ exports.ExclusionConstraintError = ExclusionConstraintError; ...@@ -217,7 +195,7 @@ exports.ExclusionConstraintError = ExclusionConstraintError;
* @param {string} type The type of the validation error * @param {string} type The type of the validation error
* @param {string} path The field that triggered the validation error * @param {string} path The field that triggered the validation error
* @param {string} value The value that generated the error * @param {string} value The value that generated the error
* @constructor * @memberof Errors
*/ */
class ValidationErrorItem { class ValidationErrorItem {
constructor(message, type, path, value) { constructor(message, type, path, value) {
...@@ -232,7 +210,7 @@ exports.ValidationErrorItem = ValidationErrorItem; ...@@ -232,7 +210,7 @@ exports.ValidationErrorItem = ValidationErrorItem;
/** /**
* A base class for all connection related errors. * A base class for all connection related errors.
* @extends BaseError * @extends BaseError
* @constructor * @memberof Errors
*/ */
class ConnectionError extends BaseError { class ConnectionError extends BaseError {
constructor(parent) { constructor(parent) {
...@@ -251,7 +229,7 @@ exports.ConnectionError = ConnectionError; ...@@ -251,7 +229,7 @@ exports.ConnectionError = ConnectionError;
/** /**
* Thrown when a connection to a database is refused * Thrown when a connection to a database is refused
* @extends ConnectionError * @extends ConnectionError
* @constructor * @memberof Errors
*/ */
class ConnectionRefusedError extends ConnectionError { class ConnectionRefusedError extends ConnectionError {
constructor(parent) { constructor(parent) {
...@@ -264,7 +242,8 @@ exports.ConnectionRefusedError = ConnectionRefusedError; ...@@ -264,7 +242,8 @@ exports.ConnectionRefusedError = ConnectionRefusedError;
/** /**
* Thrown when a connection to a database is refused due to insufficient privileges * Thrown when a connection to a database is refused due to insufficient privileges
* @extends ConnectionError * @extends ConnectionError
* @constructor * @memberof Errors
* @memberof Sequelize
*/ */
class AccessDeniedError extends ConnectionError { class AccessDeniedError extends ConnectionError {
constructor(parent) { constructor(parent) {
...@@ -277,7 +256,7 @@ exports.AccessDeniedError = AccessDeniedError; ...@@ -277,7 +256,7 @@ exports.AccessDeniedError = AccessDeniedError;
/** /**
* Thrown when a connection to a database has a hostname that was not found * Thrown when a connection to a database has a hostname that was not found
* @extends ConnectionError * @extends ConnectionError
* @constructor * @memberof Errors
*/ */
class HostNotFoundError extends ConnectionError { class HostNotFoundError extends ConnectionError {
constructor(parent) { constructor(parent) {
...@@ -290,7 +269,7 @@ exports.HostNotFoundError = HostNotFoundError; ...@@ -290,7 +269,7 @@ exports.HostNotFoundError = HostNotFoundError;
/** /**
* Thrown when a connection to a database has a hostname that was not reachable * Thrown when a connection to a database has a hostname that was not reachable
* @extends ConnectionError * @extends ConnectionError
* @constructor * @memberof Errors
*/ */
class HostNotReachableError extends ConnectionError { class HostNotReachableError extends ConnectionError {
constructor(parent) { constructor(parent) {
...@@ -303,7 +282,7 @@ exports.HostNotReachableError = HostNotReachableError; ...@@ -303,7 +282,7 @@ exports.HostNotReachableError = HostNotReachableError;
/** /**
* Thrown when a connection to a database has invalid values for any of the connection parameters * Thrown when a connection to a database has invalid values for any of the connection parameters
* @extends ConnectionError * @extends ConnectionError
* @constructor * @memberof Errors
*/ */
class InvalidConnectionError extends ConnectionError { class InvalidConnectionError extends ConnectionError {
constructor(parent) { constructor(parent) {
...@@ -316,7 +295,7 @@ exports.InvalidConnectionError = InvalidConnectionError; ...@@ -316,7 +295,7 @@ exports.InvalidConnectionError = InvalidConnectionError;
/** /**
* Thrown when a connection to a database times out * Thrown when a connection to a database times out
* @extends ConnectionError * @extends ConnectionError
* @constructor * @memberof Errors
*/ */
class ConnectionTimedOutError extends ConnectionError { class ConnectionTimedOutError extends ConnectionError {
constructor(parent) { constructor(parent) {
...@@ -329,7 +308,7 @@ exports.ConnectionTimedOutError = ConnectionTimedOutError; ...@@ -329,7 +308,7 @@ exports.ConnectionTimedOutError = ConnectionTimedOutError;
/** /**
* Thrown when a some problem occurred with Instance methods (see message for details) * Thrown when a some problem occurred with Instance methods (see message for details)
* @extends BaseError * @extends BaseError
* @constructor * @memberof Errors
*/ */
class InstanceError extends BaseError { class InstanceError extends BaseError {
constructor(message) { constructor(message) {
...@@ -343,7 +322,7 @@ exports.InstanceError = InstanceError; ...@@ -343,7 +322,7 @@ exports.InstanceError = InstanceError;
/** /**
* Thrown when a record was not found, Usually used with rejectOnEmpty mode (see message for details) * Thrown when a record was not found, Usually used with rejectOnEmpty mode (see message for details)
* @extends BaseError * @extends BaseError
* @constructor * @memberof Errors
*/ */
class EmptyResultError extends BaseError { class EmptyResultError extends BaseError {
constructor(message) { constructor(message) {
......
...@@ -10,6 +10,7 @@ const Utils = require('./utils') ...@@ -10,6 +10,7 @@ const Utils = require('./utils')
* 1. By specifying them as options in `sequelize.define` * 1. By specifying them as options in `sequelize.define`
* 2. By calling `hook()` with a string and your hook handler function * 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 * 3. By calling the function with the same name as the hook you want
*
* ```js * ```js
* // Method 1 * // Method 1
* sequelize.define(name, { attributes }, { * sequelize.define(name, { attributes }, {
...@@ -86,6 +87,7 @@ const hookAliases = { ...@@ -86,6 +87,7 @@ const hookAliases = {
/** /**
* get array of current hook and its proxied hooks combined * get array of current hook and its proxied hooks combined
* @private
*/ */
const getProxiedHooks = (hookType) => ( const getProxiedHooks = (hookType) => (
hookTypes[hookType].proxies hookTypes[hookType].proxies
...@@ -221,7 +223,7 @@ const Hooks = { ...@@ -221,7 +223,7 @@ const Hooks = {
return this; return this;
}, },
/* /**
* Check whether the mode has any hooks of this type * Check whether the mode has any hooks of this type
* *
* @param {String} hookType * @param {String} hookType
......
...@@ -14,6 +14,7 @@ const _ = require('lodash'); ...@@ -14,6 +14,7 @@ const _ = require('lodash');
* @param {Instance} modelInstance The model instance. * @param {Instance} modelInstance The model instance.
* @param {Object} options A dict with options. * @param {Object} options A dict with options.
* @constructor * @constructor
* @private
*/ */
class InstanceValidator { class InstanceValidator {
...@@ -34,6 +35,7 @@ class InstanceValidator { ...@@ -34,6 +35,7 @@ class InstanceValidator {
/** /**
* Exposes a reference to validator.js. This allows you to add custom validations using `validator.extend` * Exposes a reference to validator.js. This allows you to add custom validations using `validator.extend`
* @name validator * @name validator
* @private
*/ */
this.validator = validator; this.validator = validator;
...@@ -42,10 +44,14 @@ class InstanceValidator { ...@@ -42,10 +44,14 @@ class InstanceValidator {
* *
* @type {Array} Will contain keys that correspond to attributes which will * @type {Array} Will contain keys that correspond to attributes which will
* be Arrays of Errors. * be Arrays of Errors.
* @private
*/ */
this.errors = []; this.errors = [];
/** @type {boolean} Indicates if validations are in progress */ /**
* @type {boolean} Indicates if validations are in progress
* @private
*/
this.inProgress = false; this.inProgress = false;
extendModelValidations(modelInstance); extendModelValidations(modelInstance);
...@@ -55,6 +61,7 @@ class InstanceValidator { ...@@ -55,6 +61,7 @@ class InstanceValidator {
* The main entry point for the Validation module, invoke to start the dance. * The main entry point for the Validation module, invoke to start the dance.
* *
* @return {Promise} * @return {Promise}
* @private
*/ */
_validate() { _validate() {
if (this.inProgress) { if (this.inProgress) {
...@@ -79,6 +86,7 @@ class InstanceValidator { ...@@ -79,6 +86,7 @@ class InstanceValidator {
* - On validation failure: Validation Failed Model Hooks * - On validation failure: Validation Failed Model Hooks
* *
* @return {Promise} * @return {Promise}
* @private
*/ */
validate() { validate() {
if (this.options.hooks) { if (this.options.hooks) {
...@@ -344,7 +352,10 @@ class InstanceValidator { ...@@ -344,7 +352,10 @@ class InstanceValidator {
this.errors.push(error); 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'; InstanceValidator.RAW_KEY_NAME = '__raw';
module.exports = InstanceValidator; module.exports = InstanceValidator;
......
...@@ -40,6 +40,7 @@ class ModelManager { ...@@ -40,6 +40,7 @@ class ModelManager {
* Iterate over Models in an order suitable for e.g. creating tables. Will * Iterate over Models in an order suitable for e.g. creating tables. Will
* take foreign key constraints into account so that dependencies are visited * take foreign key constraints into account so that dependencies are visited
* before dependents. * before dependents.
* @private
*/ */
forEachModel(iterator, options) { forEachModel(iterator, options) {
const models = {}; const models = {};
......
...@@ -13,6 +13,7 @@ const QueryTypes = require('./query-types'); ...@@ -13,6 +13,7 @@ const QueryTypes = require('./query-types');
/** /**
* The interface that Sequelize uses to talk to all databases * The interface that Sequelize uses to talk to all databases
* @class QueryInterface * @class QueryInterface
* @private
*/ */
class QueryInterface { class QueryInterface {
constructor(sequelize) { constructor(sequelize) {
...@@ -765,6 +766,7 @@ class QueryInterface { ...@@ -765,6 +766,7 @@ class QueryInterface {
* Escape an identifier (e.g. a table or attribute name). If force is true, * 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 * the identifier will be quoted even if the `quoteIdentifiers` option is
* false. * false.
* @private
*/ */
quoteIdentifier(identifier, force) { quoteIdentifier(identifier, force) {
return this.QueryGenerator.quoteIdentifier(identifier, force); return this.QueryGenerator.quoteIdentifier(identifier, force);
...@@ -778,6 +780,7 @@ class QueryInterface { ...@@ -778,6 +780,7 @@ class QueryInterface {
* Split an identifier into .-separated tokens and quote each part. * Split an identifier into .-separated tokens and quote each part.
* If force is true, the identifier will be quoted even if the * If force is true, the identifier will be quoted even if the
* `quoteIdentifiers` option is false. * `quoteIdentifiers` option is false.
* @private
*/ */
quoteIdentifiers(identifiers, force) { quoteIdentifiers(identifiers, force) {
return this.QueryGenerator.quoteIdentifiers(identifiers, force); return this.QueryGenerator.quoteIdentifiers(identifiers, force);
...@@ -785,6 +788,7 @@ class QueryInterface { ...@@ -785,6 +788,7 @@ class QueryInterface {
/** /**
* Escape a value (e.g. a string, number or date) * Escape a value (e.g. a string, number or date)
* @private
*/ */
escape(value) { escape(value) {
return this.QueryGenerator.escape(value); return this.QueryGenerator.escape(value);
......
...@@ -170,20 +170,10 @@ class Transaction { ...@@ -170,20 +170,10 @@ class Transaction {
* Default to `DEFERRED` but you can override the default type by passing `options.transactionType` in `new Sequelize`. * Default to `DEFERRED` but you can override the default type by passing `options.transactionType` in `new Sequelize`.
* Sqlite only. * 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: * Pass in the desired level as the first argument:
* *
* ```js * ```js
* return sequelize.transaction({type: Sequelize.Transaction.EXCLUSIVE}, transaction => { * return sequelize.transaction({type: Sequelize.Transaction.TYPES.EXCLUSIVE}, transaction => {
* *
* // your transactions * // your transactions
* *
...@@ -193,8 +183,9 @@ class Transaction { ...@@ -193,8 +183,9 @@ class Transaction {
* // do something with the err. * // do something with the err.
* }); * });
* ``` * ```
* * @property DEFFERED
* @property TYPES * @property IMMEDIATE
* @property EXCLUSIVE
*/ */
Transaction.TYPES = { Transaction.TYPES = {
DEFERRED: 'DEFERRED', DEFERRED: 'DEFERRED',
...@@ -206,21 +197,10 @@ Transaction.TYPES = { ...@@ -206,21 +197,10 @@ Transaction.TYPES = {
* Isolations levels can be set per-transaction by passing `options.isolationLevel` to `sequelize.transaction`. * Isolations levels can be set per-transaction by passing `options.isolationLevel` to `sequelize.transaction`.
* Default to `REPEATABLE_READ` but you can override the default isolation level by passing `options.isolationLevel` in `new Sequelize`. * Default to `REPEATABLE_READ` but you can override the default isolation level by passing `options.isolationLevel` in `new Sequelize`.
* *
* 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: * Pass in the desired level as the first argument:
* *
* ```js * ```js
* return sequelize.transaction({isolationLevel: Sequelize.Transaction.SERIALIZABLE}, transaction => { * return sequelize.transaction({isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE}, transaction => {
* *
* // your transactions * // your transactions
* *
...@@ -230,8 +210,10 @@ Transaction.TYPES = { ...@@ -230,8 +210,10 @@ Transaction.TYPES = {
* // do something with the err. * // do something with the err.
* }); * });
* ``` * ```
* * @property READ_UNCOMMITTED
* @property ISOLATION_LEVELS * @property READ_COMMITTED
* @property REPEATABLE_READ
* @property SERIALIZABLE
*/ */
Transaction.ISOLATION_LEVELS = { Transaction.ISOLATION_LEVELS = {
READ_UNCOMMITTED: 'READ UNCOMMITTED', READ_UNCOMMITTED: 'READ UNCOMMITTED',
...@@ -245,15 +227,6 @@ Transaction.ISOLATION_LEVELS = { ...@@ -245,15 +227,6 @@ Transaction.ISOLATION_LEVELS = {
* *
* ```js * ```js
* t1 // is a transaction * 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({ * Model.findAll({
* where: ..., * where: ...,
* transaction: t1, * transaction: t1,
...@@ -275,7 +248,10 @@ Transaction.ISOLATION_LEVELS = { ...@@ -275,7 +248,10 @@ Transaction.ISOLATION_LEVELS = {
* ``` * ```
* UserModel will be locked but TaskModel won't! * 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 = { Transaction.LOCK = Transaction.prototype.LOCK = {
UPDATE: 'UPDATE', UPDATE: 'UPDATE',
......
...@@ -358,6 +358,7 @@ exports.toDefaultValue = toDefaultValue; ...@@ -358,6 +358,7 @@ exports.toDefaultValue = toDefaultValue;
* *
* @param {*} value Any default value. * @param {*} value Any default value.
* @return {boolean} yes / no. * @return {boolean} yes / no.
* @private
*/ */
function defaultValueSchemable(value) { function defaultValueSchemable(value) {
if (typeof value === 'undefined') { return false; } if (typeof value === 'undefined') { return false; }
...@@ -449,6 +450,7 @@ exports.removeTicks = removeTicks; ...@@ -449,6 +450,7 @@ exports.removeTicks = removeTicks;
/** /**
* Utility functions for representing SQL functions, and columns that should be escaped. * 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. * Please do not use these functions directly, use Sequelize.fn and Sequelize.col instead.
* @private
*/ */
class Fn { class Fn {
constructor(fn, args) { constructor(fn, args) {
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
const util = require('util'); const util = require('util');
const _ = require('lodash'); 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) { function inherits(constructor, superConstructor) {
util.inherits(constructor, superConstructor); // Instance (prototype) methods util.inherits(constructor, superConstructor); // Instance (prototype) methods
_.extend(constructor, superConstructor); // Static methods _.extend(constructor, superConstructor); // Static methods
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* It require a `context` for which messages will be printed. * It require a `context` for which messages will be printed.
* *
* @module logging * @module logging
* @private
*/ */
/* jshint -W030 */ /* jshint -W030 */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!