@@ -13,6 +13,8 @@ const Association = require('./base');
*
* @class HasOne
* @memberof Associations
*
* @see {@link Model.hasOne}
*/
classHasOneextendsAssociation{
constructor(srcModel,targetModel,options){
...
...
@@ -76,7 +78,7 @@ 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
* @see {@link Model#findOne} for a full explanation of options
* @return {Promise<Model>}
* @method getAssociation
* @memberof Associations.HasOne
...
...
@@ -85,7 +87,7 @@ class HasOne extends Association {
/**
* 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
...
...
@@ -97,7 +99,7 @@ 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
* @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.
* 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.
* This means that errors can be accessed using `Sequelize.ValidationError` or `sequelize.ValidationError
* 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
*/
consthookTypes={
beforeValidate:{params:2},
afterValidate:{params:2},
...
...
@@ -162,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.
* As shown above, column definitions can be either strings, a reference to one of the datatypes that are predefined on the Sequelize constructor, or an object that allows you to specify both the type of the column, and other attributes such as default values, foreign key constraints and custom setters and getters.
*
* For a list of possible data types, see http://docs.sequelizejs.com/en/latest/docs/models-definition/#data-types
*
* For more about getters and setters, see http://docs.sequelizejs.com/en/latest/docs/models-definition/#getters-setters
*
* For more about instance and class methods, see http://docs.sequelizejs.com/en/latest/docs/models-definition/#expansion-of-models
* For a list of possible data types, see {@link DataTypes}
*
* For more about validation, see http://docs.sequelizejs.com/en/latest/docs/models-definition/#validations
*
* @see {@link DataTypes}
* @see {@link Hooks}
*
* @param {String} modelName The name of the model. The model will be stored in `sequelize.models` under this name
* @param {Object} attributes An object, where each attribute is a column of the table. Each column can be either a DataType, a string or a type-description object, with the properties described below:
* @param {String|DataType|Object} attributes.column The description of a database column
* @param {String|DataType} attributes.column.type A string or a data type
* @param {String|DataTypes|Object} attributes.column The description of a database column
* @param {String|DataTypes} attributes.column.type A string or a data type
* @param {Boolean} [attributes.column.allowNull=true] If false, the column will have a NOT NULL constraint, and a not null validation will be run before an instance is saved.
* @param {any} [attributes.column.defaultValue=null] A literal default value, a JavaScript function, or an SQL function (see `sequelize.fn`)
* @param {String|Boolean} [attributes.column.unique=false] If true, the column will get a unique constraint. If a string is provided, the column will be part of a composite unique index. If multiple columns have the same string, they will be part of the same unique index
...
...
@@ -660,8 +655,6 @@ class Model {
* @param {String|Boolean} [options.updatedAt] Override the name of the updatedAt column if a string is provided, or disable it if false. Timestamps must be true. Not affected by underscored setting.
* @param {String|Boolean} [options.deletedAt] Override the name of the deletedAt column if a string is provided, or disable it if false. Timestamps must be true. Not affected by underscored setting.
* @param {String} [options.tableName] Defaults to pluralized model name, unless freezeTableName is true, in which case it uses model name verbatim
* @param {Object} [options.getterMethods] Provide getter functions that work like those defined per column. If you provide a getter method with the same name as a column, it will be used to access the value of that column. If you provide a name that does not match a column, this function will act as a virtual getter, that can fetch multiple other values
* @param {Object} [options.setterMethods] Provide setter functions that work like those defined per column. If you provide a setter method with the same name as a column, it will be used to update the value of that column. If you provide a name that does not match a column, this function will act as a virtual setter, that can act on and set other values, but will not be persisted
* @param {String} [options.schema='public']
* @param {String} [options.engine]
* @param {String} [options.charset]
...
...
@@ -2991,7 +2984,7 @@ class Model {
*
* If called with a dot.separated key on a JSON/JSONB attribute it will set the value nested and flag the entire object as changed.
*
* @see {@link Model#find} for more information about includes
* @see {@link Model#findAll} for more information about includes
* @param {String|Object} key
* @param {any} value
* @param {Object} [options]
...
...
@@ -3463,7 +3456,7 @@ class Model {
* This is different from doing a `find(Instance.id)`, because that would create and return a new instance. With this method,
* all references to the Instance are updated with the new data and no new objects are created.
*
* @see {@link Model#find}
* @see {@link Model#findAll}
* @param {Object} [options] Options that are passed on to `Model.find`
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* In addition to sequelize, the connection library for the dialect you want to use should also be installed in your project. You don't need to import it however, as sequelize will take care of that.
*
* @class Sequelize
* @lands Errors
*/
/**
...
...
@@ -286,6 +285,7 @@ class Sequelize {
* Returns an instance of QueryInterface.
* @method getQueryInterface
* @memberOf Sequelize
* @return {QueryInterface} An instance (singleton) of QueryInterface.
*/
getQueryInterface(){
...
...
@@ -331,8 +331,8 @@ class Sequelize {
*
* For more about validation, see http://docs.sequelizejs.com/en/latest/docs/models-definition/#validations
*
* @see {DataTypes}
* @see {Hooks}
* @see {@link DataTypes}
* @param {String} modelName The name of the model. The model will be stored in `sequelize.models` under this name
* @param {String} modelName The name of the model. The model will be stored in `sequelize.models` under this name
* @param {Object} attributes An object, where each attribute is a column of the table. See Model.init()
* @param {Object} [options] These options are merged with the default define options provided to the Sequelize constructor and passed to Model.init()
...
...
@@ -802,7 +802,6 @@ class Sequelize {
* })
* ```
*
* @see {@link Model#find}
* @see {@link Model#findAll}
* @see {@link Model#define}
* @see {@link Sequelize#col}
...
...
@@ -863,7 +862,7 @@ class Sequelize {
/**
* An AND query
* @see {@link Model#find}
* @see {@link Model#findAll}
*
* @method and
* @param {String|Object} args Each argument will be joined by AND
...
...
@@ -877,7 +876,7 @@ class Sequelize {
/**
* An OR query
* @see {@link Model#find}
* @see {@link Model#findAll}
*
* @method or
* @param {String|Object} args Each argument will be joined by OR
...
...
@@ -891,7 +890,7 @@ class Sequelize {
/**
* Creates an object representing nested where conditions for postgres's json data-type.
* @see {@link Model#find}
* @see {@link Model#findAll}
*
* @method json
* @param {String|Object} conditions A hash containing strings/numbers or other nested hash, a string using dot notation or a string using postgres json syntax.
...
...
@@ -911,7 +910,7 @@ class Sequelize {
*
* For string attributes, use the regular `{ where: { attr: something }}` syntax. If you don't want your string to be escaped, use `sequelize.literal`.
*
* @see {@link Model#find}
* @see {@link Model#findAll}
*
* @param {Object} attr The attribute, which can be either an attribute object from `Model.rawAttributes` or a sequelize object, for example an instance of `sequelize.fn`. For simple string attributes, use the POJO syntax