* Sync this Model to the DB, that is create the table. Upon success, the callback will be called with the model instance (this)
* Sync this Model to the DB, that is create the table.
* Upon success, the callback will be called with the model instance (this)
*
* @see {@link Sequelize#sync} for options
* @see {@link Sequelize#sync} for options
*
* @return {Promise<this>}
* @return {Promise<this>}
*/
*/
staticsync(options){
staticsync(options){
...
@@ -1316,10 +1319,12 @@ class Model {
...
@@ -1316,10 +1319,12 @@ class Model {
/**
/**
* Drop the table represented by this Model
* Drop the table represented by this Model
*
* @param {Object} [options]
* @param {Object} [options]
* @param {Boolean} [options.cascade=false] Also drop all objects depending on this table, such as views. Only works in postgres
* @param {Boolean} [options.cascade=false] Also drop all objects depending on this table, such as views. Only works in postgres
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @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).
* @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
*
* @return {Promise}
* @return {Promise}
*/
*/
staticdrop(options){
staticdrop(options){
...
@@ -1459,6 +1464,7 @@ class Model {
...
@@ -1459,6 +1464,7 @@ class Model {
* ```
* ```
*
*
* @param {Array|Object|String|null} options The scope(s) to apply. Scopes can either be passed as consecutive arguments, or as an array of arguments. To apply simple scopes and scope functions with no arguments, pass them as strings. For scope function, pass an object, with a `method` property. The value can either be a string, if the method does not take any arguments, or an array, where the first element is the name of the method, and consecutive elements are arguments to that method. Pass null to remove all scopes, including the default.
* @param {Array|Object|String|null} options The scope(s) to apply. Scopes can either be passed as consecutive arguments, or as an array of arguments. To apply simple scopes and scope functions with no arguments, pass them as strings. For scope function, pass an object, with a `method` property. The value can either be a string, if the method does not take any arguments, or an array, where the first element is the name of the method, and consecutive elements are arguments to that method. Pass null to remove all scopes, including the default.
*
* @return {Model} A reference to the model, with the scope(s) applied. Calling scope again on the returned model will clear the previous scope.
* @return {Model} A reference to the model, with the scope(s) applied. Calling scope again on the returned model will clear the previous scope.
*/
*/
staticscope(option){
staticscope(option){
...
@@ -1632,7 +1638,8 @@ class Model {
...
@@ -1632,7 +1638,8 @@ class Model {
* @param {String} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only)
* @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
* @param {Boolean|Error} [options.rejectOnEmpty=false] Throws an error when no records found
*
*
* @link {@link Sequelize.query}
* @see {@link Sequelize#query}
*
* @return {Promise<Array<Model>>}
* @return {Promise<Array<Model>>}
*/
*/
staticfindAll(options){
staticfindAll(options){
...
@@ -1999,6 +2006,8 @@ class Model {
...
@@ -1999,6 +2006,8 @@ class Model {
* @param {Object} [findOptions] See findAll
* @param {Object} [findOptions] See findAll
*
*
* @see {@link Model.findAll} for a specification of find and query 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.
* Builds a new model instance and calls save on it.
* @see {@link Model#build}
* @see {@link Model.build}
* @see {@link Model#save}
* @see {@link Model.save}
*
*
* @param {Object} values
* @param {Object} values
* @param {Object} [options]
* @param {Object} [options]
...
@@ -2185,11 +2194,13 @@ class Model {
...
@@ -2185,11 +2194,13 @@ 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.
* 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.
* 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
*
* @param {Object} options
* @param {Object} options
* @param {Object} options.where where A hash of search attributes.
* @param {Object} options.where where A hash of search attributes.
* @param {Object} [options.defaults] Default values to use if creating a new instance
* @param {Object} [options.defaults] Default values to use if creating a new instance
* @param {Transaction} [options.transaction] Transaction to run query under
* @param {Transaction} [options.transaction] Transaction to run query under
* @see {@link Model.findAll} for a full specification of find and options
*
* @return {Promise<Model,created>}
* @return {Promise<Model,created>}
*/
*/
staticfindOrCreate(options){
staticfindOrCreate(options){
...
@@ -2292,10 +2303,12 @@ class Model {
...
@@ -2292,10 +2303,12 @@ class Model {
* A more performant findOrCreate that will not work under a transaction (at least not in postgres)
* 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
* 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
*
* @param {Object} options
* @param {Object} options
* @param {Object} options.where where A hash of search attributes.
* @param {Object} options.where A hash of search attributes.
* @param {Object} [options.defaults] Default values to use if creating a new instance
* @param {Object} [options.defaults] Default values to use if creating a new instance
* @see {@link Model.findAll} for a full specification of find and options
*
* @return {Promise<Model,created>}
* @return {Promise<Model,created>}
*/
*/
staticfindCreateFind(options){
staticfindCreateFind(options){
...
@@ -2600,7 +2613,7 @@ class Model {
...
@@ -2600,7 +2613,7 @@ class Model {
*
*
* @return {Promise}
* @return {Promise}
*
*
* @see {@link Model#destroy} for more information
* @see {@link Model.destroy} for more information
*/
*/
statictruncate(options){
statictruncate(options){
options=Utils.cloneDeep(options)||{};
options=Utils.cloneDeep(options)||{};
...
@@ -2623,6 +2636,7 @@ class Model {
...
@@ -2623,6 +2636,7 @@ class Model {
* @param {Transaction} [options.transaction] Transaction to run query under
* @param {Transaction} [options.transaction] Transaction to run query under
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @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).
* @param {Boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging).
*
* @return {Promise<Integer>} The number of destroyed rows
* @return {Promise<Integer>} The number of destroyed rows