@@ -362,15 +362,16 @@ class BelongsToMany extends Association {
/**
* Get everything currently associated with this, using an optional where clause.
*
* @see {@link Model.findAll} for a full explanation of options
* @see
* {@link Model} for a full explanation of options
*
* @param {<Model>} instance instance
* @param {Model} instance instance
* @param {Object} [options] find options
* @param {Object} [options.where] An optional where clause to limit the associated models
* @param {string|boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
* @param {string} [options.schema] Apply a schema on the related model
*
* @returns {Promise<Array<<Model>>>}
* @returns {Promise<Array<Model>>}
*/
get(instance,options){
options=Utils.cloneDeep(options)||{};
...
...
@@ -433,7 +434,7 @@ class BelongsToMany extends Association {
/**
* Count everything currently associated with this, using an optional where clause.
*
* @param {<Model>} instance instance
* @param {Model} instance instance
* @param {Object} [options] find options
* @param {Object} [options.where] An optional where clause to limit the associated models
* @param {string|boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
...
...
@@ -458,8 +459,8 @@ class BelongsToMany extends Association {
/**
* Check if one or more instance(s) are associated with this. If a list of instances is passed, the function returns true if _all_ instances are associated
*
* @param {<Model>} sourceInstance source instance to check for an association with
* @param {<Model>|<Model>[]|string[]|string|number[]|number} [instances] Can be an array of instances or their primary keys
* @param {Model} sourceInstance source instance to check for an association with
* @param {Model|Model[]|string[]|string|number[]|number} [instances] Can be an array of instances or their primary keys
* @param {Object} [options] Options passed to getAssociations
*
* @returns {Promise<boolean>}
...
...
@@ -502,8 +503,8 @@ class BelongsToMany extends Association {
* 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 {<Model>} sourceInstance source instance to associate new instances with
* @param {<Model>|<Model>[]|string[]|string|number[]|number} [newAssociatedObjects] A single instance or primary key, or a mixed array of persisted instances or primary keys
* @param {Model} sourceInstance source instance to associate new instances with
* @param {Model|Model[]|string[]|string|number[]|number} [newAssociatedObjects] A single instance or primary key, or a mixed array of persisted instances or primary keys
* @param {Object} [options] Options passed to `through.findAll`, `bulkCreate`, `update` and `destroy`
* @param {Object} [options.validate] Run validation for the join model
* @param {Object} [options.through] Additional attributes for the join table.
...
...
@@ -610,8 +611,8 @@ class BelongsToMany extends Association {
* Associate one ore several rows with source instance. It will not un-associate any already assoicated instance
* that may be missing from `newInstances`.
*
* @param {<Model>} sourceInstance source instance to associate new instances with
* @param {<Model>|<Model>[]|string[]|string|number[]|number} [newInstances] A single instance or primary key, or a mixed array of persisted instances or primary keys
* @param {Model} sourceInstance source instance to associate new instances with
* @param {Model|Model[]|string[]|string|number[]|number} [newInstances] A single instance or primary key, or a mixed array of persisted instances or primary keys
* @param {Object} [options] Options passed to `through.findAll`, `bulkCreate` and `update`
* @param {Object} [options.validate] Run validation for the join model.
* @param {Object} [options.through] Additional attributes for the join table.
...
...
@@ -706,8 +707,8 @@ class BelongsToMany extends Association {
/**
* Un-associate one or more instance(s).
*
* @param {<Model>} sourceInstance instance to un associate instances with
* @param {<Model>|<Model>[]|string|string[]|number|number[]} [oldAssociatedObjects] Can be an Instance or its primary key, or a mixed array of instances and primary keys
* @param {Model} sourceInstance instance to un associate instances with
* @param {Model|Model[]|string|string[]|number|number[]} [oldAssociatedObjects] Can be an Instance or its primary key, or a mixed array of instances and primary keys
* @param {Object} [options] Options passed to `through.destroy`
*
* @returns {Promise}
...
...
@@ -730,7 +731,7 @@ class BelongsToMany extends Association {
/**
* Create a new instance of the associated model and associate it with this.
*
* @param {<Model>} sourceInstance source instance
* @param {Model} sourceInstance source instance
* @param {Object} [values] values for target model
* @param {Object} [options] Options passed to create and add
* @param {Object} [options.through] Additional attributes for the join table
* @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 {@link Model.findOne} for a full explanation of options
* @see
* {@link Model.findOne} for a full explanation of options
*
* @returns {Promise<<Model>>}
* @returns {Promise<Model>}
*/
get(instances,options){
constwhere={};
...
...
@@ -183,7 +184,7 @@ class BelongsTo extends Association {
/**
* Set the associated model.
*
* @param {<Model>} sourceInstance the source instance
* @param {Model} sourceInstance the source instance
* @param {?<Model>|string|number} [associatedInstance] An persisted instance or the primary key of an instance to associate with this. Pass `null` or `undefined` to remove the association.
* @param {Object} [options={}] options passed to `this.save`
* @param {boolean} [options.save=true] Skip saving this after setting the foreign key if false.
...
...
@@ -214,11 +215,12 @@ class BelongsTo extends Association {
/**
* Create a new instance of the associated model and associate it with this.
*
* @param {<Model>} sourceInstance the source instance
* @param {Model} sourceInstance the source instance
* @param {Object} [values={}] values to create associated model instance with
* @param {Object} [options={}] Options passed to `target.create` and setAssociation.
*
* @see {@link Model#create} for a full explanation of options
* @see
* {@link Model#create} for a full explanation of options
*
* @returns {Promise<Model>} The created target model
* @param {Object} [options.where] An optional where clause to limit the associated models
* @param {string|boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
* @param {string} [options.schema] Apply a schema on the related model
*
* @see {@link Model.findAll} for a full explanation of options
* @see
* {@link Model.findAll} for a full explanation of options
*
* @returns {Promise<Array<<Model>>>}
* @returns {Promise<Array<Model>>}
*/
get(instances,options={}){
constwhere={};
...
...
@@ -241,7 +242,7 @@ class HasMany extends Association {
/**
* Count everything currently associated with this, using an optional where clause.
*
* @param {<Model>} instance the source instance
* @param {Model} instance the source instance
* @param {Object} [options] find & count options
* @param {Object} [options.where] An optional where clause to limit the associated models
* @param {string|boolean} [options.scope] Apply a scope on the related model, or remove its default scope by passing false
...
...
@@ -269,8 +270,8 @@ class HasMany extends Association {
/**
* Check if one or more rows are associated with `this`.
*
* @param {<Model>} sourceInstance the source instance
* @param {<Model>|<Model>[]|string[]|string|number[]|number} [targetInstances] Can be an array of instances or their primary keys
* @param {Model} sourceInstance the source instance
* @param {Model|Model[]|string[]|string|number[]|number} [targetInstances] Can be an array of instances or their primary keys
* @param {Object} [options] Options passed to getAssociations
*
* @returns {Promise}
...
...
@@ -310,8 +311,8 @@ class HasMany extends Association {
/**
* 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 {<Model>} sourceInstance source instance to associate new instances with
* @param {<Model>|<Model>[]|string[]|string|number[]|number} [targetInstances] An array of persisted instances or primary key of instances to associate with this. Pass `null` or `undefined` to remove all associations.
* @param {Model} sourceInstance source instance to associate new instances with
* @param {Model|Model[]|string[]|string|number[]|number} [targetInstances] An array of persisted instances or primary key of instances to associate with this. Pass `null` or `undefined` to remove all associations.
* @param {Object} [options] Options passed to `target.findAll` and `update`.
* @param {Object} [options.validate] Run validation for the join model
*
...
...
@@ -385,8 +386,8 @@ class HasMany extends Association {
* Associate one or more target rows with `this`. This method accepts a Model / string / number to associate a single row,
* or a mixed array of Model / string / numbers to associate multiple rows.
*
* @param {<Model>} sourceInstance the source instance
* @param {<Model>|<Model>[]|string[]|string|number[]|number} [targetInstances] A single instance or primary key, or a mixed array of persisted instances or primary keys
* @param {Model} sourceInstance the source instance
* @param {Model|Model[]|string[]|string|number[]|number} [targetInstances] A single instance or primary key, or a mixed array of persisted instances or primary keys
* @param {Object} [options] Options passed to `target.update`.
*
* @returns {Promise}
...
...
@@ -413,8 +414,8 @@ class HasMany extends Association {
/**
* Un-associate one or several target rows.
*
* @param {<Model>} sourceInstance instance to un associate instances with
* @param {<Model>|<Model>[]|string|string[]|number|number[]} [targetInstances] Can be an Instance or its primary key, or a mixed array of instances and primary keys
* @param {Model} sourceInstance instance to un associate instances with
* @param {Model|Model[]|string|string[]|number|number[]} [targetInstances] Can be an Instance or its primary key, or a mixed array of instances and primary keys
* @param {Object} [options] Options passed to `target.update`
*
* @returns {Promise}
...
...
@@ -439,7 +440,7 @@ class HasMany extends Association {
/**
* Create a new instance of the associated model and associate it with this.
*
* @param {<Model>} sourceInstance source instance
* @param {Model} sourceInstance source instance
* @param {Object} [values] values for target model instance
* @param {Object} [options] Options passed to `target.create`
* @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 {@link Model.findOne} for a full explanation of options
* @see
* {@link Model.findOne} for a full explanation of options
*
* @returns {Promise<Model>}
*/
...
...
@@ -183,7 +184,7 @@ class HasOne extends Association {
/**
* Set the associated model.
*
* @param {<Model>} sourceInstance the source instance
* @param {Model} sourceInstance the source instance
* @param {?<Model>|string|number} [associatedInstance] 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 getAssociation and `target.save`
*
...
...
@@ -233,11 +234,12 @@ class HasOne extends Association {
/**
* Create a new instance of the associated model and associate it with this.
*
* @param {<Model>} sourceInstance the source instance
* @param {Model} sourceInstance the source instance
* @param {Object} [values={}] values to create associated model instance with
* @param {Object} [options] Options passed to `target.create` and setAssociation.
*
* @see {@link Model#create} for a full explanation of options
* @see
* {@link Model#create} for a full explanation of options
*
* @returns {Promise<Model>} The created target model
@@ -34,8 +34,8 @@ const Op = require('./operators');
* However, if getters and/or setters are defined for `field` they will be invoked, instead of returning the value from `dataValues`.
* Accessing properties directly or using `get` is preferred for regular use, `getDataValue` should only be used for custom getters.
*
* @see {@link Sequelize#define} for more information about getters and setters
* @class Model
* @see
* {@link Sequelize#define} for more information about getters and setters
* @mixes Hooks
*/
classModel{
...
...
@@ -50,7 +50,8 @@ class Model {
/**
* A reference to the sequelize instance
*
* @see {@link Sequelize}
* @see
* {@link Sequelize}
*
* @property sequelize
*
...
...
@@ -848,8 +849,10 @@ class Model {
*
* sequelize.models.modelName // The model will now be available in models under the class name
*
* @see {@link DataTypes}
* @see {@link Hooks}
* @see
* {@link DataTypes}
* @see
* {@link Hooks}
*
* @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|DataTypes|Object} attributes.column The description of a database column
...
...
@@ -1251,7 +1254,8 @@ class Model {
*
* @param {Object} [options] sync options
*
* @see {@link Sequelize#sync} for options
* @see
* {@link Sequelize#sync} for options
*
* @returns {Promise<Model>}
*/
...
...
@@ -1389,7 +1393,8 @@ class Model {
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @param {boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
*
* @see {@link Sequelize#define} for more information about setting a default schema.
* @see
* {@link Sequelize#define} for more information about setting a default schema.
*
* @returns {Model}
*/
...
...
@@ -1611,7 +1616,8 @@ class Model {
*
* # WHERE `Model`.`name` = 'a project' AND (`Model`.`id` IN (1, 2, 3) OR (`Model`.`id` > 10 AND `Model`.`id` < 100));
*
* @see {@link Operators} for possible operators
* @see
* {@link Operators} for possible operators
* __Alias__: _all_
*
* The promise is resolved with an array of Model instances if the query succeeds._
...
...
@@ -1648,7 +1654,8 @@ class Model {
* @param {string} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only)
* @param {boolean|Error} [options.rejectOnEmpty=false] Throws an error when no records found
*
* @see {@link Sequelize#query}
* @see
* {@link Sequelize#query}
*
* @returns {Promise<Array<Model>>}
*/
...
...
@@ -1846,7 +1853,8 @@ class Model {
* @param {Transaction} [options.transaction] Transaction to run query under
* @param {string} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only)
*
* @see {@link Model.findAll} for a full explanation of options
* @see
* {@link Model.findAll} for a full explanation of options
*
* @returns {Promise<Model>}
*/
...
...
@@ -1879,7 +1887,8 @@ class Model {
* @param {Transaction} [options.transaction] Transaction to run query under
* @param {string} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only)
*
* @see {@link Model.findAll} for an explanation of options
* @see
* {@link Model.findAll} for an explanation of options
*
* @returns {Promise<Model>}
*/
...
...
@@ -1964,7 +1973,7 @@ class Model {
return0;
}
returnvalue;
});;
});
}
/**
...
...
@@ -2042,8 +2051,10 @@ class Model {
*
* @param {Object} [options] See findAll options
*
* @see {@link Model.findAll} for a specification of find and query options
* @see {@link Model.count} for a specification of count options
* @see
* {@link Model.findAll} for a specification of find and query options
* @see
* {@link Model.count} for a specification of count options
* Builds a new model instance and calls save on it.
* @see {@link Model.build}
* @see {@link Model.save}
* @see
* {@link Model.build}
* @see
* {@link Model.save}
*
* @param {Object} values hash of data values to create new record with
* @param {Object} [options] build and query options
...
...
@@ -2231,7 +2247,8 @@ class Model {
* However, it is not always possible to handle this case in SQLite, specifically if one transaction inserts and another tries to select before the first one has committed. In this case, an instance of sequelize. TimeoutError will be thrown instead.
* If a transaction is created, a savepoint will be created instead, and any unique constraint violation will be handled internally.
*
* @see {@link Model.findAll} for a full specification of find and options
* @see
* {@link Model.findAll} for a full specification of find and options
*
* @param {Object} options find and create options
* @param {Object} options.where where A hash of search attributes.
...
...
@@ -2340,7 +2357,8 @@ class Model {
* A more performant findOrCreate that will not work under a transaction (at least not in postgres)
* Will execute a find call, if empty then attempt to create, if unique constraint then attempt to find again
*
* @see {@link Model.findAll} for a full specification of find and options
* @see
* {@link Model.findAll} for a full specification of find and options
*
* @param {Object} options find options
* @param {Object} options.where A hash of search attributes.
...
...
@@ -2655,7 +2673,8 @@ class Model {
*
* @returns {Promise}
*
* @see {@link Model.destroy} for more information
* @see
* {@link Model.destroy} for more information
*/
statictruncate(options){
options=Utils.cloneDeep(options)||{};
...
...
@@ -3110,7 +3129,8 @@ class Model {
* // `by` is ignored, as each column has its own value
* @param {string|Array|Object} fields If a string is provided, that column is incremented by the value of `by` given in options. If an array is provided, the same is true for each column. If and object is provided, each column is incremented by the value given.
* @param {Object} options increment options
...
...
@@ -3202,8 +3222,10 @@ class Model {
* @param {string|Array|Object} fields If a string is provided, that column is incremented by the value of `by` given in options. If an array is provided, the same is true for each column. If and object is provided, each column is incremented by the value given.
* @param {Object} options decrement options, similar to increment
*
* @see {@link Model.increment}
* @see {@link Model#reload}
* @see
* {@link Model.increment}
* @see
* {@link Model#reload}
* @since 4.36.0
* @returns {Promise<Model[],?number>} returns an array of affected rows and affected count with `options.returning: true`, whenever supported by dialect
...
...
@@ -3366,7 +3388,8 @@ 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.findAll} for more information about includes
* @see
* {@link Model.findAll} for more information about includes
*
* @param {string|Object} key key to set, it can be string or object. When string it will set that key, for object it will loop over all object properties nd set them.
* @param {any} value value to set
...
...
@@ -3374,7 +3397,7 @@ class Model {
* @param {boolean} [options.raw=false] If set to true, field and virtual setters will be ignored
* @param {boolean} [options.reset=false] Clear all previously set data values
*
* @returns {<Model>}
* @returns {Model}
*/
set(key,value,options){
letvalues;
...
...
@@ -3607,7 +3630,7 @@ class Model {
* @param {string} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only)
* @param {boolean} [options.returning] Append RETURNING * to get back auto generated values (Postgres only)
* @param {string|Array|Object} fields If a string is provided, that column is incremented by the value of `by` given in options. If an array is provided, the same is true for each column. If and object is provided, each column is incremented by the value given.
* @param {Object} [options] options
...
...
@@ -4104,7 +4131,7 @@ class Model {
* @param {string} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only)
* @param {boolean} [options.returning=true] Append RETURNING * to get back auto generated values (Postgres only)
*
* @returns {Promise<<Model>>}
* @returns {Promise<Model>}
* @since 4.0.0
*/
increment(fields,options){
...
...
@@ -4133,7 +4160,8 @@ class Model {
* // `by` is ignored, since each column has its own value
* @param {string|Array|Object} fields If a string is provided, that column is decremented by the value of `by` given in options. If an array is provided, the same is true for each column. If and object is provided, each column is decremented by the value given
* @param {Object} [options] drecrement options
* @param {number} [options.by=1] The number to decrement by
...
...
@@ -4156,7 +4184,7 @@ class Model {
/**
* Check whether this and `other` Instance refer to the same row
*
* @param {<Model>} other Other instance to compare against
* @param {Model} other Other instance to compare against
*
* @returns {boolean}
*/
...
...
@@ -4192,7 +4220,8 @@ class Model {
* Proxies to calling `get` with no keys.
* This means get all values gotten from the DB, and apply all custom getters.
@@ -25,8 +25,6 @@ const Op = require('./operators');
/**
* This is the main class, the entry point to sequelize.
*
* @class Sequelize
*/
classSequelize{
/**
...
...
@@ -59,7 +57,7 @@ class Sequelize {
* @param {string} [options.password=null] The password which is used to authenticate against the database.
* @param {string} [options.database=null] The name of the database
* @param {string} [options.dialect] The dialect of the database you are connecting to. One of mysql, postgres, sqlite and mssql.
* @param {String} [options.dialectModule=null] If specified, use this dialect library. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify 'require("pg.js")' here
* @param {string} [options.dialectModule=null] If specified, use this dialect library. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify 'require("pg.js")' here
* @param {string} [options.dialectModulePath=null] If specified, load the dialect library from this path. For example, if you want to use pg.js instead of pg when connecting to a pg database, you should specify '/path/to/pg.js' here
* @param {Object} [options.dialectOptions] An object of additional options, which are passed directly to the connection library
* @param {string} [options.storage] Only used by sqlite. Defaults to ':memory:'
...
...
@@ -158,6 +156,7 @@ class Sequelize {
sync:{},
timezone:'+00:00',
clientMinMessages:'warning',
// eslint-disable-next-line no-console
logging:console.log,
omitNull:false,
native:false,
...
...
@@ -193,6 +192,7 @@ class Sequelize {
if(this.options.logging===true){
logger.deprecate('The logging-option should be either a function or false. Default: console.log');
// eslint-disable-next-line no-console
this.options.logging=console.log;
}
...
...
@@ -319,9 +319,11 @@ class Sequelize {
* @param {Object} attributes An object, where each attribute is a column of the table. See {@link Model.init}
* @param {Object} [options] These options are merged with the default define options provided to the Sequelize constructor and passed to Model.init()
*
* @see {@link Model.init} for a more comprehensive specification of the `options` and `attributes` objects.
* @see
* {@link Model.init} for a more comprehensive specification of the `options` and `attributes` objects.
* @see <a href="/manual/tutorial/models-definition.html">Model definition</a> Manual related to model definition
* @see {@link DataTypes} For a list of possible data types
* @see
* {@link DataTypes} For a list of possible data types
consterror=newError(`${options.transaction.finished} has been called on this transaction(${options.transaction.id}), you can no longer use it. (The rejected query is attached as the \'sql\' property of this error)`);
consterror=newError(`${options.transaction.finished} has been called on this transaction(${options.transaction.id}), you can no longer use it. (The rejected query is attached as the 'sql' property of this error)`);
error.sql=sql;
throwerror;
}
...
...
@@ -636,7 +639,8 @@ class Sequelize {
* **Note:** this is a schema in the [postgres sense of the word](http://www.postgresql.org/docs/9.1/static/ddl-schemas.html),
* not a database table. In mysql and sqlite, this command will do nothing.
*
* @see {@link Model.schema}
* @see
* {@link Model.schema}
*
* @param {string} schema Name of the schema
* @param {Object} [options={}] query options
...
...
@@ -759,7 +763,8 @@ class Sequelize {
* @param {boolean|Function} [options.logging] A function that logs sql queries, or false for no logging
* @returns {Promise}
*
* @see {@link Model.truncate} for more information
* @see
* {@link Model.truncate} for more information
*/
truncate(options){
constmodels=[];
...
...
@@ -782,7 +787,8 @@ class Sequelize {
* Drop all tables defined through this sequelize instance.
* This is done by calling Model.drop on each model.
*
* @see {@link Model.drop} for options
* @see
* {@link Model.drop} for options
*
* @param {Object} [options] The options passed to each call to Model.drop
* @param {boolean|Function} [options.logging] A function that logs sql queries, or false for no logging
...
...
@@ -839,9 +845,12 @@ class Sequelize {
* Creates an object representing a database function. This can be used in search queries, both in where and order parts, and as default values in column definitions.
* If you want to refer to columns in your function, you should use `sequelize.col`, so that the columns are properly interpreted as columns and not a strings.
*
* @see {@link Model.findAll}
* @see {@link Sequelize.define}
* @see {@link Sequelize.col}
* @see
* {@link Model.findAll}
* @see
* {@link Sequelize.define}
* @see
* {@link Sequelize.col}
*
* @param {string} fn The function you want to call
* @param {any} args All further arguments will be passed as arguments to the function
...
...
@@ -862,7 +871,8 @@ class Sequelize {
/**
* Creates an object which represents a column in the DB, this allows referencing another column in your query. This is often useful in conjunction with `sequelize.fn`, since raw string arguments to fn will be escaped.
*
* @see {@link Sequelize#fn}
* @see
* {@link Sequelize#fn}
*
* @param {string} col The name of the column
* @since v2.0.0-dev3
...
...
@@ -904,7 +914,8 @@ class Sequelize {
/**
* An AND query
*
* @see {@link Model.findAll}
* @see
* {@link Model.findAll}
*
* @param {...string|Object} args Each argument will be joined by AND
* @since v2.0.0-dev3
...
...
@@ -919,7 +930,8 @@ class Sequelize {
/**
* An OR query
*
* @see {@link Model.findAll}
* @see
* {@link Model.findAll}
*
* @param {...string|Object} args Each argument will be joined by OR
* @since v2.0.0-dev3
...
...
@@ -934,7 +946,8 @@ class Sequelize {
/**
* Creates an object representing nested where conditions for postgres/sqlite/mysql json data-type.
*
* @see {@link Model.findAll}
* @see
* {@link Model.findAll}
*
* @param {string|Object} conditionsOrPath A hash containing strings/numbers or other nested hash, a string using dot notation or a string using postgres/sqlite/mysql json syntax.
* @param {string|number|boolean} [value] An optional value to compare against. Produces a string of the form "<json path> = '<value>'".
...
...
@@ -954,7 +967,8 @@ 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.findAll}
* @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
* @param {Symbol} [comparator='Op.eq'] operator
...
...
@@ -1080,6 +1094,7 @@ class Sequelize {
options=last;
// remove options from set of logged arguments if options.logging is equal to console.log
// eslint-disable-next-line no-console
if(options.logging===console.log){
args.splice(args.length-1,1);
}
...
...
@@ -1090,10 +1105,12 @@ class Sequelize {
if(options.logging){
if(options.logging===true){
logger.deprecate('The logging-option should be either a function or false. Default: console.log');
// eslint-disable-next-line no-console
options.logging=console.log;
}
// second argument is sql-timings, when benchmarking option enabled
expectation:'CREATE TABLE IF NOT EXISTS \"myTable\" (\"int\" INTEGER , \"foo\" INTEGER ); COMMENT ON COLUMN \"myTable\".\"int\" IS \'Test\'; COMMENT ON COLUMN \"myTable\".\"foo\" IS \'Foo Comment\';'
expectation:'CREATE TABLE IF NOT EXISTS "myTable" ("int" INTEGER , "foo" INTEGER ); COMMENT ON COLUMN "myTable"."int" IS \'Test\'; COMMENT ON COLUMN "myTable"."foo" IS \'Foo Comment\';'
expectation:'CREATE TABLE IF NOT EXISTS \"myTable\" (\"title\" VARCHAR(255), \"name\" VARCHAR(255), \"id\" INTEGER , PRIMARY KEY (\"id\"));'
expectation:'CREATE TABLE IF NOT EXISTS "myTable" ("title" VARCHAR(255), "name" VARCHAR(255), "id" INTEGER , PRIMARY KEY ("id"));'
},
{
arguments:['myTable',{title:'VARCHAR(255)',name:'VARCHAR(255)',otherId:'INTEGER REFERENCES "otherTable" ("id") ON DELETE CASCADE ON UPDATE NO ACTION'}],
expectation:'CREATE TABLE IF NOT EXISTS \"myTable\" (\"title\" VARCHAR(255), \"name\" VARCHAR(255), \"otherId\" INTEGER REFERENCES \"otherTable\" (\"id\") ON DELETE CASCADE ON UPDATE NO ACTION);'
expectation:'CREATE TABLE IF NOT EXISTS "myTable" ("title" VARCHAR(255), "name" VARCHAR(255), "otherId" INTEGER REFERENCES "otherTable" ("id") ON DELETE CASCADE ON UPDATE NO ACTION);'
},
// Variants when quoteIdentifiers is false
...
...
@@ -251,19 +251,19 @@ if (dialect.startsWith('postgres')) {
postgres:'DELETE FROM "public"."test_users" WHERE "id" IN (SELECT "id" FROM "public"."test_users" WHERE "name" = \'foo\'\';DROP TABLE mySchema.myTable;\' LIMIT 10)',
mariadb:"DELETE FROM `public`.`test_users` WHERE `name` = 'foo\\';DROP TABLE mySchema.myTable;' LIMIT 10",
sqlite:"DELETE FROM `public.test_users` WHERE rowid IN (SELECT rowid FROM `public.test_users` WHERE `name` = \'foo\'\';DROP TABLE mySchema.myTable;\' LIMIT 10)",
sqlite:"DELETE FROM `public.test_users` WHERE rowid IN (SELECT rowid FROM `public.test_users` WHERE `name` = 'foo'';DROP TABLE mySchema.myTable;' LIMIT 10)",
mssql:"DELETE TOP(10) FROM [public].[test_users] WHERE [name] = N'foo'';DROP TABLE mySchema.myTable;'; SELECT @@ROWCOUNT AS AFFECTEDROWS;",
default:"DELETE FROM [public.test_users] WHERE `name` = 'foo\\';DROP TABLE mySchema.myTable;' LIMIT 10"