* A DAOFactory represents a table in the database. Sometimes you might also see it refererred to as model, or simply as factory. This class should _not_ be instantiated directly, It is created using `sequelize.define`, and already created models can be loaded using `sequelize.import`
* @param {Object} options Options to describe the scope of the search.
* @param {Object|Number} options A hush of options to describe the scope of the search, or a number to search by id.
* @param {Array} include A list of associations which shall get eagerly loaded. Supported is either { include: [ DaoFactory1, DaoFactory2, ...] } or { include: [ { daoFactory: DaoFactory1, as: 'Alias' } ] }.
* @param {Object} [options.where]
* @param {Object} set the query options, e.g. raw, specifying that you want raw data instead of built DAOs
* @param {Array<String>} [options.attributes] A list of the attributes that you want to select
* @return {Object} A promise which fires `success`, `error`, `complete` and `sql`.
* @param {Array<Object|DAOFactory>} [options.include] A list of associations which shall get eagerly loaded. Supported is either { include: [ DaoFactory1, DaoFactory2, ...] } or { include: [ { daoFactory: DaoFactory1, as: 'Alias' } ] }.
* @param {String|Array} [options.order]
* @param {Number} [options.limit]
* @param {Number} [options.offset]
* @param {Object} queryOptions set the query options, e.g. raw, specifying that you want raw data instead of built DAOs. See sequelize.query for options
* @param {Transaction} queryOptions.transaction
*
* @return {EventEmitter} Fires `success`, `error` and `sql`. Upon success, a DAO will be return to the sucess listener
* @param {Array} records List of objects (key/value pairs) to create instances from
* @param {Array} records List of objects (key/value pairs) to create instances from
* @param {Array} fields Fields to insert (defaults to all fields)
* @param {Object} [options]
* @return {Object} A promise which fires `success`, `error`, `complete` and `sql`.
* @param {Array} [options.fields] Fields to insert (defaults to all fields)
*
* @param {Boolean} [options.validate=false] Should each row be subject to validation before it is inserted. The whole insert will fail if one row fails validation
* Note: the `success` handler is not passed any arguments. To obtain DAOs for
* @param {Boolean} [options.hooks=false] Run before / after bulkCreate hooks?
* the newly created values, you will need to query for them again. This is
* @param {Boolean} [options.ignoreDuplicates=false] Ignore duplicate values for primary keys? (not supported by postgres)
* because MySQL and SQLite do not make it easy to obtain back automatically
*
* generated IDs and other default values in a way that can be mapped to
* @return {EventEmitter} Fires `success`, `error` and `sql`. The success` handler is not passed any arguments. To obtain DAOs for the newly created values, you will need to query for them again. This is because MySQL and SQLite do not make it easy to obtain back automatically generated IDs and other default values in a way that can be mapped to multiple records
* @param {Object} where Options to describe the scope of the search.
* @param {Object} where Options to describe the scope of the search.
* @param {Object} options Possible options are:
* @param {Object} options:
- hooks: If set to true, destroy will find all records within the where parameter and will execute before/afterDestroy hooks on each row
* @param {Boolean} options.hooks If set to true, destroy will find all records within the where parameter and will execute before/afterDestroy hooks on each row
- limit: How many rows to delete
* @param {Number} options.limit How many rows to delete
- truncate: If set to true, dialects that support it will use TRUNCATE instead of DELETE FROM. If a table is truncated the where and limit options are ignored
* @param {Boolean} options.truncate If set to true, dialects that support it will use TRUNCATE instead of DELETE FROM. If a table is truncated the where and limit options are ignored
* @return {Object} A promise which fires `success`, `error`, `complete` and `sql`.
*
* @return {EventEmitter} Fires `success`, `error` and `sql`.
* @param {Object} attrValueHash A hash of fields to change and their new values
* @param {Object} attrValueHash A hash of fields to change and their new values
* @param {Object} where Options to describe the scope of the search.
* @param {Object where Options to describe the scope of the search. Note that these options are not wrapped in a { where: ... } is in find / findAll calls etc. This is probably due to change in 2.0
* @return {Object} A promise which fires `success`, `error`, `complete` and `sql`.
* @param {Object} options
* @param {Boolean} [options.validate=true] Should each row be subject to validation before it is inserted. The whole insert will fail if one row fails validation
* @param {Boolean} [options.hooks=false] Run before / after bulkUpdate hooks?
*
* @return {EventEmitter} A promise which fires `success`, `error` and `sql`.
* This class represents an single instance, a database column. You might see it referred to as both DAO and instance.
* This class represents an single instance, a database column. You might see it referred to as both DAO and instance.
*
*
* DAO instances operate with the concept of a `dataValues` property, which stores the actual values represented by this DAO. By default, the values from dataValues can also be accessed directly from the DAO, that is:
* DAO instances operate with the concept of a `dataValues` property, which stores the actual values represented by this DAO. By default, the values from dataValues can also be accessed directly from the DAO, that is:
```js
* ```js
instance.field
* instance.field
// is the same as
* // is the same as
instance.get('field')
* instance.get('field')
// is the same as
* // is the same as
instance.getDataValue('field')
* instance.getDataValue('field')
```
* ```
* However, if getters and/or setters are defined for `field` they will be invoked, instead of returning the value from `dataValues`.
* However, if getters and/or setters are defined for `field` they will be invoked, instead of returning the value from `dataValues`.
* @see {Sequelize#define} Sequelize#define for more information about getters and setters
* @see {Sequelize#define} Sequelize#define for more information about getters and setters
* 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: function () {
* // 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
*/
varHooks=module.exports=function(){}
varHooks=module.exports=function(){}
varhookAliases={
varhookAliases={
beforeDelete:"beforeDestroy",
beforeDelete:"beforeDestroy",
...
@@ -65,11 +96,21 @@ Hooks.runHooks = function() {
...
@@ -65,11 +96,21 @@ Hooks.runHooks = function() {
run(hooks[tick])
run(hooks[tick])
}
}
// Alias for `.addHook`
/**
* Alias of addHook
* @see {Hooks#addHook}
*/
Hooks.hook=function(){
Hooks.hook=function(){
Hooks.addHook.apply(this,arguments)
Hooks.addHook.apply(this,arguments)
}
}
/**
* Add a hook to the model
*
* @param {String} hooktype
* @param {String} [name] Provide a name for the hooks function. This serves no purpose other than the ability/capability for the future to order hooks based on either a priority system or by before/after a specific hook.
* An object of different query types. This is used when doing raw queries (sequlize.query). If no type is provided to .query, sequelize will try to guess the correct type based on your SQL. This might not always work if you query is formatted in a special way
* An object of different query types. This is used when doing raw queries (sequlize.query). If no type is provided to .query, sequelize will try to guess the correct type based on your SQL. This might not always work if you query is formatted in a special way
* For more about instance and class methods see http://sequelizejs.com/docs/latest/models#expansion-of-models
* For more about instance and class methods see http://sequelizejs.com/docs/latest/models#expansion-of-models
*
*
* @see {DataTypes}
* @see {DataTypes}
* @see {Hooks}
* @param {String} daoName
* @param {String} daoName
* @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 {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|Object} attributes.column The description of a database column
* @param {Object} [options.hooks] An object of hook function that are called before and after certain lifecycle events. The possible hooks are: beforeValidate, afterValidate, beforeBulkCreate, beforeBulkDestroy, beforeBulkUpdate, beforeCreate, beforeDestroy, beforeUpdate, afterCreate, afterDestroy, afterUpdate, afterBulkCreate, afterBulkDestory and afterBulkUpdate. See Hooks for more information about hook functions and their signatures. Each property can either be a function, or an array of function.
_This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on [IRC](irc://irc.freenode.net/#sequelizejs), open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org), [dox](https://github.com/visionmedia/dox) and [markdox](https://github.com/cbou/markdox)_
_This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on [IRC](irc://irc.freenode.net/#sequelizejs), open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org) and [markdox](https://github.com/cbou/markdox)_
_This documentation was automagically created on <?= new Date().toString() ?>_
_This documentation was automagically created on <?= new Date().toString() ?>_