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

Commit c0b82bd5 by Jan Aagaard Meier

Finished api docs for sequelize.js and dao.js

1 parent 9e608982
......@@ -296,6 +296,11 @@ module.exports = (function() {
this.DAO.prototype.attributes = Object.keys(this.DAO.prototype.rawAttributes)
}
/**
* Sync this DAO to the DB.
* @see {Sequelize#sync} for options
* @return {EventEmitter}
*/
DAOFactory.prototype.sync = function(options) {
options = Utils._.extend({}, this.options, options || {})
......
......@@ -6,6 +6,22 @@ var Utils = require("./utils")
, _ = require('lodash')
module.exports = (function() {
/**
* 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:
```js
instance.field
// is the same as
instance.get('field')
// is the same as
instance.getDataValue('field')
```
* 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
* @class DAO
*/
var DAO = function(values, options) {
this.dataValues = {}
this._previousDataValues = {}
......@@ -15,39 +31,86 @@ module.exports = (function() {
// What is selected values even used for?
this.selectedValues = options.include ? _.omit(values, options.includeNames) : values
this.__eagerlyLoadedAssociations = []
/**
* Returns true if this instance has not yet been persisted to the database
* @property isNewRecord
* @return {Boolean}
*/
this.isNewRecord = options.isNewRecord
/**
* Returns the Model the instance was created from.
* @see {DAOFactory}
* @property Model
* @return DAOFactory
*/
initValues.call(this, values, options);
}
Utils._.extend(DAO.prototype, Mixin.prototype)
/**
* A reference to the sequelize instance
* @see {Sequelize}
* @property sequelize
* @return the sequelize instance
*/
Object.defineProperty(DAO.prototype, 'sequelize', {
get: function(){ return this.__factory.daoFactoryManager.sequelize }
})
/**
* A reference to the query interface
* @property QueryInterface
* @see {QueryInterface}
* @return {QueryInterface}
*/
Object.defineProperty(DAO.prototype, 'QueryInterface', {
get: function(){ return this.sequelize.getQueryInterface() }
})
/**
* If timestamps and paranoid are enabled, returns whether the deletedAt timestamp of this instance is set. Otherwise, always returns false.
* @property isDeleted
* @return {Boolean}
*/
Object.defineProperty(DAO.prototype, 'isDeleted', {
get: function() {
return this.Model._timestampAttributes.deletedAt && this.dataValues[this.Model._timestampAttributes.deletedAt] !== null
}
})
/**
* Get the values of this DAO. Proxies to this.get
* @see {DAO#get}
* @property values
* @return {Object}
*/
Object.defineProperty(DAO.prototype, 'values', {
get: function() {
return this.get()
}
})
/**
* A getter for this.changed()
*
* @see {DAO#changed}
* @property isDirty
* @return {Boolean}
*/
Object.defineProperty(DAO.prototype, 'isDirty', {
get: function() {
return !!this.changed()
}
})
/**
* Get the values of the primary keys of this instance.
* @property primaryKeyValues
* @return {Object} The values of thep primary keys for this DAO
*/
Object.defineProperty(DAO.prototype, 'primaryKeyValues', {
get: function() {
var result = {}
......@@ -79,13 +142,33 @@ module.exports = (function() {
}
})
/**
* Get the value of the underlying data value
*
* @param {String} key
* @return {any}
*/
DAO.prototype.getDataValue = function(key) {
return this.dataValues[key]
}
/**
* Update the underlying data value
*
* @param {String} key
* @param {any} value
*/
DAO.prototype.setDataValue = function(key, value) {
this.dataValues[key] = value
}
/**
* If no key is given, returns all values of the instance.
*
* If key is given and a field or virtual getter is present for the key it will call the getter with key - else it will return the value for key.
* @param {String} [key]
* @return {Object|any} If no key is given, all values will be returned as a hash. If key is given, the value of that column / virtual getter will be returned
*/
DAO.prototype.get = function (key) {
if (key) {
if (this._customGetters[key]) {
......@@ -113,12 +196,26 @@ module.exports = (function() {
}
return this.dataValues
}
/**
* If values is an object and raw is true and no includes are in the Instance options, set will set dataValues to values, or extend it if it exists.
* Else values will be looped and a recursive set will be kalled with key and value from the hash.
* If set is called with a key and a value and the key matches an include option, it will build the child include with the value.
* If raw is false and a field or virtual setter is present for the key, it will call the setter with (value, key) - else it will set instance value for key to value.
*
* @see {DAOFactory#find} DAOFactory#find for more information about includes
* @param {String|Object} key(s)
* @param {any} value
* @param {Object} [options]
* @param {Boolean} [options.raw=false] If set to true, field and virtual setters will be ignored
* @param {Boolean} [options.reset] TODO ????
*/
DAO.prototype.set = function (key, value, options) {
var values
, originalValue
if (typeof key === "object") {
values = key
values = keys
options = value
options || (options = {})
......@@ -197,6 +294,13 @@ module.exports = (function() {
}
}
/**
* If changed is called with a string it will return `true|false` depending on whether the value(s) are `dataValues` is different from the value(s) in `_previousDataValues`.
*
* If changed is called without an argument, it will return an array of keys that have changed.
* @param {String} [key]
* @return {Boolean|Array} A boolean if key is provided, otherwise an array of all attributes that have changed
*/
DAO.prototype.changed = function(key) {
if (key) {
if (this._isDateAttribute(key) && this._previousDataValues[key] && this.dataValues[key]) {
......@@ -211,6 +315,11 @@ module.exports = (function() {
return changed.length ? changed : false
}
/**
* Returns the previous value for key from _previousDataValues.
* @param {String} key
* @return {Boolean}
*/
DAO.prototype.previous = function(key) {
return this._previousDataValues[key]
}
......@@ -263,8 +372,16 @@ module.exports = (function() {
}.bind(this))
};
// if an array with field names is passed to save()
// only those fields will be updated
/**
* Persist this instance to the database
*
* @param {Array} [fields] An optional array of string, representing database columns. If fields is provided, only those columns will be saved.
* @param {Object} [options]
* @param {Object} [options.fields] An alternative way of setting which fields should be persisted
* @param {Transaction} [options.transaction]
* @return {EventEmitter}
* @fires error, success, sql
*/
DAO.prototype.save = function(fieldsOrOptions, options) {
if (fieldsOrOptions instanceof Array) {
fieldsOrOptions = { fields: fieldsOrOptions }
......@@ -441,7 +558,10 @@ module.exports = (function() {
* This is different from doing a `find(DAO.id)`, because that would create and return a new object. With this method,
* all references to the DAO are updated with the new data and no new objects are created.
*
* @return {Object} A promise which fires `success`, `error`, `complete` and `sql`.
* @see {DAO#find}
* @param {Object} [options] Options that are passed on to DAO#find
* @return {EventEmitter}
* @fires error, success, sql
*/
DAO.prototype.reload = function(options) {
var where = [
......@@ -468,10 +588,12 @@ module.exports = (function() {
/*
* Validate this dao's attribute values according to validation rules set in the dao definition.
*
* @return null if and only if validation successful; otherwise an object containing { field name : [error msgs] } entries.
* @param {Object} [options] Options that are passed to the validator
* @param {Array} [options.skip] An array of strings. All properties that are in this array will not be validated
* @return {Object|null} null if and only if validation successful; otherwise an object containing { field name : [error msgs] } entries.
*/
DAO.prototype.validate = function(object) {
var validator = new DaoValidator(this, object)
DAO.prototype.validate = function(options) {
var validator = new DaoValidator(this, options)
, errors = validator.validate()
return (Utils._.isEmpty(errors) ? null : errors)
......@@ -488,6 +610,17 @@ module.exports = (function() {
return validator.hookValidate()
}
/**
* This is the same as calling setAttributes, then calling save
*
* @see {DAO#setAttributes}
* @see {DAO#save}
* @param {Object} updates See setAttributes
* @param {Object} options See save
*
* @return {EventEmitter}
* @fires error, success, sql
*/
DAO.prototype.updateAttributes = function(updates, options) {
if (options instanceof Array) {
options = { fields: options }
......@@ -497,10 +630,26 @@ module.exports = (function() {
return this.save(options)
}
/**
* Update multiple attributes at once. The values are updated by calling set
*
* @see {DAO#set}
* @param {Object} updates A hash of values to update
* @return {EventEmitter}
* @fires error, success, sql
*/
DAO.prototype.setAttributes = function(updates) {
this.set(updates)
}
/**
* Destroy the column corresponding to this DAO object. Depending on your setting for paranoid, the row will either be completely deleted, or have its deletedAt timestamp set to the current timestamp.
*
* @param {Object} [options={}]
* @param {Boolean} [options.force=false] If set to true, paranoid models will actually be deleted
* @return {EventEmitter}
* @fires error, success, sql
*/
DAO.prototype.destroy = function(options) {
options = options || {}
options.force = options.force === undefined ? false : Boolean(options.force)
......@@ -541,6 +690,27 @@ module.exports = (function() {
}).run()
}
/**
* Increment the value of one or more columns. This is done in the database, which means it does not use the values currently stored on the DAO. The increment is done using a
```sql
SET column = column + X
```
query. To get the correct value after an increment into the DAO you should do a reload.
```js
instance.increment('number') increment number by 1
instance.increment(['number', 'count'], { by: 2 }) increment number and count by 2
instance.increment({ answer: 42, tries: 1}, { by: 1 }) increment answer by 42, and tries by 1. `by` is ignore, since each column has its own value
```
*
* @see {DAO#reload}
* @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]
* @param {Integer} [options.by=1] The number to increment by
* @param {Transaction} [options.transaction=null]
* @return {EventEmitter}
* @fires error, success, sql
*/
DAO.prototype.increment = function(fields, countOrOptions) {
Utils.validateParameter(countOrOptions, Object, {
optional: true,
......@@ -580,6 +750,27 @@ module.exports = (function() {
return this.QueryInterface.increment(this, this.QueryInterface.QueryGenerator.addSchema(this.__factory.tableName, this.__factory.options.schema), values, identifier, countOrOptions)
}
/**
* Increment the value of one or more columns. This is done in the database, which means it does not use the values currently stored on the DAO. The decrement is done using a
```sql
SET column = column - X
```
query. To get the correct value after an decrement into the DAO you should do a reload.
```js
instance.decrement('number') decrement number by 1
instance.decrement(['number', 'count'], { by: 2 }) decrement number and count by 2
instance.decrement({ answer: 42, tries: 1}, { by: 1 }) decrement answer by 42, and tries by 1. `by` is ignore, since each column has its own value
```
*
* @see {DAO#reload}
* @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]
* @param {Integer} [options.by=1] The number to decrement by
* @param {Transaction} [options.transaction=null]
* @return {EventEmitter}
* @fires error, success, sql
*/
DAO.prototype.decrement = function (fields, countOrOptions) {
Utils.validateParameter(countOrOptions, Object, {
optional: true,
......
......@@ -50,7 +50,7 @@ module.exports = (function() {
* @param {String} [options.host='localhost'] The host of the relational database.
* @param {Integer} [options.port=] The port of the relational database.
* @param {String} [options.protocol='tcp'] The protocol of the relational database.
* @param {Object} [options.define={}] Options, which shall be default for every model definition.
* @param {Object} [options.define={}] Options, which shall be default for every model definition. See sequelize#define for options
* @param {Object} [options.query={}] I have absolutely no idea.
* @param {Object} [options.sync={}] Options, which shall be default for every `sync` call.
* @param {Function} [options.logging=console.log] A function that gets executed everytime Sequelize would log something.
......@@ -146,12 +146,21 @@ module.exports = (function() {
}
this.daoFactoryManager = new DAOFactoryManager(this)
this.transactionManager = new TransactionManager(this)
this.importCache = {}
}
/**
* A reference to Utils
* @see {Utils}
*/
Sequelize.Utils = Utils
/**
* 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
* @see sequelize#query
* @see {QueryTypes}
*/
Sequelize.QueryTypes = QueryTypes
for (var dataType in DataTypes) {
......@@ -159,8 +168,12 @@ module.exports = (function() {
}
/**
* Polyfill for the default connector manager.
* @ignore
* Direct access to the sequelize connectorManager
*
* @name connectorManager
* @property connectorManager
* @readonly
* @see {ConnectorManager}
*/
Object.defineProperty(Sequelize.prototype, 'connectorManager', {
get: function() {
......@@ -169,6 +182,12 @@ module.exports = (function() {
})
/**
* A reference to transaction. Use this to access isolationLevels when creating a transaction
* @see {Transaction}
*/
Sequelize.prototype.Transaction = Transaction
/**
* Returns the specified dialect.
*
* @return {String} The specified dialect.
......@@ -184,7 +203,6 @@ module.exports = (function() {
* @return {QueryInterface} An instance (singleton) of QueryInterface.
*
* @see {QueryInterface}
* @link {QueryInterface}
*/
Sequelize.prototype.getQueryInterface = function() {
this.queryInterface = this.queryInterface || new QueryInterface(this)
......@@ -211,6 +229,70 @@ module.exports = (function() {
return this.migrator
}
/**
* Define a new model, representing a table in the DB.
*
* The table columns are define by the hash that is given as the second argument. Each attribute of the hash represents a column. A short table definition might look like this:
*
* ```js
* sequelize.define(..., {
* columnA: {
* type: Sequelize.BOOLEAN,
* // Other attributes here
* },
* columnB: Sequelize.STRING,
* columnC: 'MY VERY OWN COLUMN TYPE'
* })
* ```
*
* For a list of possible data types, see http://sequelizejs.com/docs/latest/models#data-types
*
* For more about getters and setters, see http://sequelizejs.com/docs/latest/models#getters---setters
*
* For more about instance and class methods see http://sequelizejs.com/docs/latest/models#expansion-of-models
*
* @see {DataTypes}
* @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 {String|DataType|Object} attributes.column The description of a database column
* @param {String|DataType} 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
* @param {Boolean} [attributes.column.defaultValue=null] A literal default value, or a 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
* @param {Boolean} [attributes.column.primaryKey=false]
* @param {Boolean} [attributes.column.autoIncrement=false]
* @param {String} [attributes.column.comment=null]
* @param {String|DAOFactory} [attributes.column.references] If this column references another table, provide it here as a DAOFactory, or a string
* @param {String} [attributes.column.referencesKey='id'] The column of the foreign table that this column references
* @param {String} [attributes.column.onUpdate] What should happen when the referenced key is updated. One of CASCADE, RESTRICT or NO ACTION
* @param {String} [attributes.column.onDelete] What should happen when the referenced key is deleted. One of CASCADE, RESTRICT or NO ACTION
* @param {Function} [attributes.column.get] Provide a custom getter for this column. Use this.getDataValue(String) and this.setDataValue(String, Value) to manipulate the underlying values.
* @param {Function} [attributes.column.set] Provide a custom setter for this column. Use this.getDataValue(String) and this.setDataValue(String, Value) to manipulate the underlying values.
* @param {Object} [options] These options are merged with the options provided to the Sequelize constructor
* @param {Boolean} [options.omitNull] Don't persits null values. This means that all columns with null values will not be saved
* @param {Boolean} [options.timestamps=true] Handle createdAt and updatedAt timestamps
* @param {Boolean} [options.paranoid=false] Calling destroy will not delete the model, but instead set a deletedAt timestamp if this is true. Needs timestamps=true to work
* @param {Boolean} [options.underscored=false] Converts all camelCased columns to underscored if true
* @param {Boolean} [options.freezeTableName=false] If freezeTableName is true, sequelize will not try to alter the DAO name to get the table name. Otherwise, the tablename will be pluralized
* @param {String|Boolean} [options.createdAt] Override the name of the createdAt column if a string is provided, or disable it if true. Timestamps must be true
* @param {String|Boolean} [options.updatedAt] Override the name of the updatedAt column if a string is provided, or disable it if true. Timestamps must be true
* @param {String|Boolean} [options.deletedAt] Override the name of the deletedAt column if a string is provided, or disable it if true. Timestamps must be true
* @param {String} [options.tableName] Defaults to pluralized DAO name
* @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 {Object} [options.instanceMethods] Provide functions that are added to each instance (DAO)
* @param {Object} [options.classMethods] Provide functions that are added to the model (DAOFactory)
* @param {String} [options.schema='public']
* @param {String} [options.engine]
* @param {Strng} [options.charset]
* @param {String} [options.comment]
* @param {String} [options.collate]
*
* @return {DaoFactory}
* TODO validation
* TODO hooks
*/
Sequelize.prototype.define = function(daoName, attributes, options) {
options = options || {}
var self = this
......@@ -282,10 +364,11 @@ module.exports = (function() {
}
/**
* Fetch a DAO factory
* Fetch a DAO factory which is already defined
*
* @param {String} daoName The name of a model defined with Sequelize.define
* @returns {DAOFactory} The DAOFactory for daoName
* @throws Will throw an error if the DAO is not define (that is, if sequelize#isDefined returns false)
* @return {DAOFactory} The DAOFactory for daoName
*/
Sequelize.prototype.model = function(daoName) {
if(!this.isDefined(daoName)) {
......@@ -295,11 +378,26 @@ module.exports = (function() {
return this.daoFactoryManager.getDAO(daoName)
}
/**
* Checks whether a DAO with the given name is defined
*
* @param {String} daoName The name of a model defined with Sequelize.define
* @return {Boolean} Is a DAO with that name already defined?
*/
Sequelize.prototype.isDefined = function(daoName) {
var daos = this.daoFactoryManager.daos
return (daos.filter(function(dao) { return dao.name === daoName }).length !== 0)
}
/**
* Imports a DAO defined in another file
*
* Imported DAOs are cached, so multiple calls to import with the same path will not load the file multiple times
*
* See https://github.com/sequelize/sequelize/blob/master/examples/using-multiple-model-files/Task.js for a short example of how to define your models in separate files so that they can be imported by sequelize.import
* @param {String} path The path to the file that holds the model you want to import. If the part is relative, it will be resolved relatively to the calling file
* @return {DAOFactory}
*/
Sequelize.prototype.import = function(path) {
// is it a relative path?
if (Path.normalize(path).indexOf(path.sep) !== 0) {
......@@ -328,8 +426,12 @@ module.exports = (function() {
* @method query
* @param {String} sql
* @param {DAOFactory} [callee] If callee is provided, the selected data will be used to build an instance of the DAO represented by the factory. Equivalent to calling DAOFactory.build with the values provided by the query.
* @param {Object} [options={}] Query options. See above for a full set of options
* @param {Object} [options={}] Query options.
* @param {Boolean} [options.raw] If true, sequelize will not try to format the results of the query, or build an instance of a model from the result
* @param {String} [options.type] What is the type of this query (SELECT, UPDATE etc.). If the query starts with SELECT, the type will be assumed to be SELECT, otherwise no assumptions are made. Only used when raw is false.
* @param {Transaction} [options.transaction=null] The transaction that the query should be executed under
* @param {Object|Array} [replacements] Either an object of named parameter replacements in the format `:param` or an array of unnamed replacements to replace `?`
* @return {EventEmitter}
*
* @see {DAOFactory#build} for more information about callee.
*/
......@@ -340,6 +442,7 @@ module.exports = (function() {
* @method query
* @param {String} sql
* @param {Object} [options={raw:true}] Query options. See above for a full set of options
* @return {EventEmitter}
*/
Sequelize.prototype.query = function(sql, callee, options, replacements) {
if (arguments.length === 4) {
......@@ -366,6 +469,11 @@ module.exports = (function() {
return this.transactionManager.query(sql, callee, options)
}
/**
* Create a new database schema
* @param {String} schema Name of the schema
* @return {EventEmitter}
*/
Sequelize.prototype.createSchema = function(schema) {
var chainer = new Utils.QueryChainer()
......@@ -374,6 +482,10 @@ module.exports = (function() {
return chainer.run()
}
/**
* Show all defined schemas
* @return {EventEmitter}
*/
Sequelize.prototype.showAllSchemas = function() {
var chainer = new Utils.QueryChainer()
......@@ -382,6 +494,11 @@ module.exports = (function() {
return chainer.run()
}
/**
* Drop a single schema
* @param {String} schema Name of the schema
* @return {EventEmitter}
*/
Sequelize.prototype.dropSchema = function(schema) {
var chainer = new Utils.QueryChainer()
......@@ -390,6 +507,10 @@ module.exports = (function() {
return chainer.run()
}
/**
* Drop all schemas
* @return {EventEmitter}
*/
Sequelize.prototype.dropAllSchemas = function() {
var self = this
......@@ -398,6 +519,15 @@ module.exports = (function() {
return chainer.run()
}
/**
* Sync all defined DAOs to the DB.
*
* @param {Object} [options={}]
* @param {Boolean} [options.force=false] If force is true, each DAO will do DROP TABLE IF EXISTS ..., before it tries to create its own table
* @param {Boolean|function} [options.logging=console.log] A function that logs sql queries, or false for no logging
* @param {String} [options.schema='public'] The schema that the tables should be created in. This can be overriden for each table in sequelize.define
* @return {EventEmitter}
*/
Sequelize.prototype.sync = function(options) {
options = options || {}
......@@ -438,19 +568,12 @@ module.exports = (function() {
}).run()
}
/**
* Test the connetion by trying to authenticate
* @method authenticate
* @param {boolean} cake want cake?
* @param {string} a something else
*/
/**
* Test the connetion by trying to authenticate
* @method authenticate
* @param {string} k something else
*/
* Test the connetion by trying to authenticate
* @return {EventEmitter}
* @fires success If authentication was successfull
* @error 'Invalid credentials' if the authentication failed (even if the database did not respond at all....)
*/
Sequelize.prototype.authenticate = function() {
var self = this
......@@ -467,36 +590,116 @@ module.exports = (function() {
}).run()
}
/**
* Alias of authenticate
*
* @see {Sequelize#authenticate}
* @return {EventEmitter}
* @fires success If authentication was successfull
* @error 'Invalid credentials' if the authentication failed (even if the database did not respond at all....)
*/
Sequelize.prototype.validate = Sequelize.prototype.authenticate;
/**
* Creates a 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 {DAOFactory#find}
* @see {DAOFactory#findAll}
* @see {DAOFactory#define}
* @see {Sequelize#col}
*
* @method fn
* @param {String} fn The function you want to call
* @param {any} args All further arguments will be passed as arguments to the function
* @return An instance of Sequelize.fn
*/
Sequelize.fn = Sequelize.prototype.fn = function (fn) {
return new Utils.fn(fn, Array.prototype.slice.call(arguments, 1))
}
/**
* Creates a object representing a column in the DB. This is usefull in sequelize.fn, since raw string arguments to that will be escaped.
* @see Sequelize#fn
*
* @method col
* @param {String} col The name of the column
* @return An instance of Sequelize.col
*/
Sequelize.col = Sequelize.prototype.col = function (col) {
return new Utils.col(col)
}
/**
* Creates a object representing a call to the cast function.
*
* @method cast
* @param {any} val The value to cast
* @param {String} type The type to cast it to
* @return An instance of Sequelize.cast
*/
Sequelize.cast = Sequelize.prototype.cast = function (val, type) {
return new Utils.cast(val, type)
}
/**
* Creates a object representing a literal, i.e. something that will not be escaped.
*
* @method literal
* @param {any} val
* @return An instance of Sequelize.literal
*/
Sequelize.literal = Sequelize.prototype.literal = function (val) {
return new Utils.literal(val)
}
/**
* An alias of literal
* @method asIs
* @see {Sequelize#literal}
*/
Sequelize.asIs = Sequelize.prototype.asIs = function (val) {
return new Utils.asIs(val)
}
/**
* An AND query
* @see {DAOFactory#find}
*
* @method and
* @param {String|Object} args Each argument will be joined by AND
* @return An instance of Sequelize.and
*/
Sequelize.and = Sequelize.prototype.and = function() {
return new Utils.and(Array.prototype.slice.call(arguments))
}
/**
* An OR query
* @see {DAOFactory#find}
*
* @method or
* @param {String|Object} args Each argument will be joined by OR
* @return An instance of Sequelize.or
*/
Sequelize.or = Sequelize.prototype.or = function() {
return new Utils.or(Array.prototype.slice.call(arguments))
}
/**
* Start a transaction.
* @see {Transaction}
* @param {Object} [options={}]
* @param {Boolean} [options.autocommit=true]
* @param {String} [options.isolationLevel='REPEATABLE_READ'] One of READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE. It is preferred to use sequelize.Transaction.ISOLATION_LEVELS as opposed to providing a string
* @param {Function} callback Called when the transaction has been set up and is ready for use. If the callback takes two arguments it will be called with err, transaction, otherwise it will be called with transaction.
* @return {Transaction}
* @fires error If there is an uncaught error during the transaction
* @fires success When the transaction has ended (either comitted or rolled back)
*/
Sequelize.prototype.transaction = function(_options, _callback) {
var options = (typeof _options === 'function') ? {} : _options
, callback = (typeof _options === 'function') ? _options : _callback
......
var markdox = require('markdox');
var markdox = require('markdox')
, ghm = require("github-flavored-markdown")
, fs = require('fs')
, _ = require('lodash');
var getTag = function(tags, tagName) {
return _.find(tags, function (tag) {
return tag.type === tagName
});
};
// TODO multiple @see tags
var options = {
output: 'output.md',
formatter: function (docfile) {
docfile = markdox.defaultFormatter(docfile);
docfile.members = [];
docfile.javadoc.forEach(function(javadoc, index){
var isConstructor = false;
javadoc.raw.tags.forEach(function(tag){
if (tag.type == 'constructor') {
isConstructor = true
// Find constructor tags
docfile.javadoc[index].isConstructor = getTag(javadoc.raw.tags, 'constructor') !== undefined;
// Only show params without a dot in them (dots means attributes of object, so no need to clutter the co)
var params = []
javadoc.paramTags.forEach(function (paramTag) {
if (paramTag.name.indexOf('.') === -1) {
params.push(paramTag.name);
}
});
javadoc.paramStr = params.join(', ');
// Handle linking in comments
if (javadoc.see) {
if (javadoc.see.indexOf('{') === 0){
var see = javadoc.see.split('}')
see[0] = see[0].substring(1)
if (javadoc.see.indexOf('www') !== -1) {
javadoc.seeExternal = true
} else {
javadoc.seeExternal = false
}
javadoc.seeURL = see[0]
if (see[1] !== "") {
javadoc.seeText = see[1]
} else {
javadoc.seeText = see[0]
}
} else {
javadoc.seeURL = false
}
}
docfile.javadoc[index].isConstructor = isConstructor;
// Set a name for properties
if (!javadoc.name) {
var property = getTag(javadoc.raw.tags, 'property')
if (property) {
javadoc.name = property.string
}
}
if (!javadoc.isClass) {
docfile.members.push(javadoc.name)
}
});
return docfile;
......@@ -24,5 +70,8 @@ var options = {
};
markdox.process('./lib/sequelize.js', options, function(){
console.log('File `all.md` generated with success');
});
\ No newline at end of file
md = fs.readFileSync('output.md').toString();
fs.writeFileSync('out.html', ghm.parse(md));
});
<!-- Start ./lib/sequelize.js -->
<a name="Sequelize" />
### Sequelize
The main class
### Members:
* <a href="#Sequelize">Sequelize</a>
* <a href="#Sequelize">Sequelize</a>
* <a href="#Utils">Utils</a>
* <a href="#QueryTypes">QueryTypes</a>
* <a href="#connectorManager">connectorManager</a>
* <a href="#Transaction">Transaction</a>
* <a href="#getDialect">getDialect</a>
* <a href="#getQueryInterface">getQueryInterface</a>
* <a href="#getMigrator">getMigrator</a>
* <a href="#define">define</a>
* <a href="#model">model</a>
* <a href="#isDefined">isDefined</a>
* <a href="#import">import</a>
* <a href="#query">query</a>
* <a href="#query">query</a>
* <a href="#createSchema">createSchema</a>
* <a href="#showAllSchemas">showAllSchemas</a>
* <a href="#dropSchema">dropSchema</a>
* <a href="#dropAllSchemas">dropAllSchemas</a>
* <a href="#sync">sync</a>
* <a href="#authenticate">authenticate</a>
* <a href="#fn">fn</a>
* <a href="#col">col</a>
* <a href="#cast">cast</a>
* <a href="#literal">literal</a>
* <a href="#asIs">asIs</a>
* <a href="#and">and</a>
* <a href="#or">or</a>
* <a href="#transaction">transaction</a>
------
## new Sequelize()
<a name="Sequelize" />
## new Sequelize(database, [username=null], [password=null], [options={}])
Instantiate sequelize with name of database, username and password
......@@ -94,7 +128,7 @@ var sequelize = new Sequelize('mysql://localhost:3306/database', {})
<tr>
<td>[options.define={}]</td>
<td>Object</td>
<td>Options, which shall be default for every model definition.</td>
<td>Options, which shall be default for every model definition. See sequelize#define for options</td>
</tr>
<tr>
......@@ -155,7 +189,9 @@ var sequelize = new Sequelize('mysql://localhost:3306/database', {})
------
## new Sequelize()
<a name="Sequelize" />
## new Sequelize(uri, [options={}])
Instantiate sequlize with an URI
......@@ -181,8 +217,48 @@ Instantiate sequlize with an URI
------
<a name="Utils" />
### Utils
A reference to Utils
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-Utils">Utils</a>
------
<a name="QueryTypes" />
### QueryTypes
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
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-QueryTypes">QueryTypes</a>
------
<a name="connectorManager" />
### connectorManager
Direct access to the sequelize connectorManager
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-ConnectorManager">ConnectorManager</a>
------
<a name="Transaction" />
### Transaction
A reference to transaction. Use this to access isolationLevels when creating a transaction
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-Transaction">Transaction</a>
------
<a name="getDialect" />
### getDialect()
Returns the specified dialect.
......@@ -193,11 +269,13 @@ Returns the specified dialect.
------
<a name="getQueryInterface" />
### getQueryInterface()
Returns an instance of QueryInterface.
See: {QueryInterface}
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-QueryInterface">QueryInterface</a>
#### Return:
......@@ -205,6 +283,8 @@ See: {QueryInterface}
------
<a name="getMigrator" />
### getMigrator([options={}], [force=false])
Returns an instance (singleton) of Migrator.
......@@ -235,9 +315,262 @@ Returns an instance (singleton) of Migrator.
------
<a name="define" />
### define(daoName, attributes, [options])
Define a new model, representing a table in the DB.
The table columns are define by the hash that is given as the second argument. Each attribute of the hash represents a column. A short table definition might look like this:
```js
sequelize.define(..., {
columnA: {
type: Sequelize.BOOLEAN,
// Other attributes here
},
columnB: Sequelize.STRING,
columnC: 'MY VERY OWN COLUMN TYPE'
})
```
For a list of possible data types, see http://sequelizejs.com/docs/latest/models#data-types
For more about getters and setters, see http://sequelizejs.com/docs/latest/models#getters---setters
For more about instance and class methods see http://sequelizejs.com/docs/latest/models#expansion-of-models
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-DataTypes">DataTypes</a>
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>daoName</td>
<td>String</td>
<td></td>
</tr>
<tr>
<td>attributes</td>
<td>Object</td>
<td>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:</td>
</tr>
<tr>
<td>attributes.column</td>
<td>String|DataType|Object</td>
<td>The description of a database column</td>
</tr>
<tr>
<td>attributes.column.type</td>
<td>String|DataType</td>
<td>A string or a data type</td>
</tr>
<tr>
<td>[attributes.column.allowNull=true]</td>
<td>Boolean</td>
<td>If false, the column will have a NOT NULL constraint</td>
</tr>
<tr>
<td>[attributes.column.defaultValue=null]</td>
<td>Boolean</td>
<td>A literal default value, or a function, see sequelize#fn</td>
</tr>
<tr>
<td>[attributes.column.unique=false]</td>
<td>String|Boolean</td>
<td>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</td>
</tr>
<tr>
<td>[attributes.column.primaryKey=false]</td>
<td>Boolean</td>
<td></td>
</tr>
<tr>
<td>[attributes.column.autoIncrement=false]</td>
<td>Boolean</td>
<td></td>
</tr>
<tr>
<td>[attributes.column.comment=null]</td>
<td>String</td>
<td></td>
</tr>
<tr>
<td>[attributes.column.references]</td>
<td>String|DAOFactory</td>
<td>If this column references another table, provide it here as a DAOFactory, or a string</td>
</tr>
<tr>
<td>[attributes.column.referencesKey='id']</td>
<td>String</td>
<td>The column of the foreign table that this column references</td>
</tr>
<tr>
<td>[attributes.column.onUpdate]</td>
<td>String</td>
<td>What should happen when the referenced key is updated. One of CASCADE, RESTRICT or NO ACTION</td>
</tr>
<tr>
<td>[attributes.column.onDelete]</td>
<td>String</td>
<td>What should happen when the referenced key is deleted. One of CASCADE, RESTRICT or NO ACTION</td>
</tr>
<tr>
<td>[attributes.column.get]</td>
<td>Function</td>
<td>Provide a custom getter for this column. Use this.getDataValue(String) and this.setDataValue(String, Value) to manipulate the underlying values.</td>
</tr>
<tr>
<td>[attributes.column.set]</td>
<td>Function</td>
<td>Provide a custom setter for this column. Use this.getDataValue(String) and this.setDataValue(String, Value) to manipulate the underlying values.</td>
</tr>
<tr>
<td>[options]</td>
<td>Object</td>
<td>These options are merged with the options provided to the Sequelize constructor</td>
</tr>
<tr>
<td>[options.omitNull]</td>
<td>Boolean</td>
<td>Don't persits null values. This means that all columns with null values will not be saved</td>
</tr>
<tr>
<td>[options.timestamps=true]</td>
<td>Boolean</td>
<td>Handle createdAt and updatedAt timestamps</td>
</tr>
<tr>
<td>[options.paranoid=false]</td>
<td>Boolean</td>
<td>Calling destroy will not delete the model, but instead set a deletedAt timestamp if this is true. Needs timestamps=true to work</td>
</tr>
<tr>
<td>[options.underscored=false]</td>
<td>Boolean</td>
<td>Converts all camelCased columns to underscored if true</td>
</tr>
<tr>
<td>[options.freezeTableName=false]</td>
<td>Boolean</td>
<td>If freezeTableName is true, sequelize will not try to alter the DAO name to get the table name. Otherwise, the tablename will be pluralized</td>
</tr>
<tr>
<td>[options.createdAt]</td>
<td>String|Boolean</td>
<td>Override the name of the createdAt column if a string is provided, or disable it if true. Timestamps must be true</td>
</tr>
<tr>
<td>[options.updatedAt]</td>
<td>String|Boolean</td>
<td>Override the name of the updatedAt column if a string is provided, or disable it if true. Timestamps must be true</td>
</tr>
<tr>
<td>[options.deletedAt]</td>
<td>String|Boolean</td>
<td>Override the name of the deletedAt column if a string is provided, or disable it if true. Timestamps must be true</td>
</tr>
<tr>
<td>[options.tableName]</td>
<td>String</td>
<td>Defaults to pluralized DAO name</td>
</tr>
<tr>
<td>[options.getterMethods]</td>
<td>Object</td>
<td>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</td>
</tr>
<tr>
<td>[options.setterMethods]</td>
<td>Object</td>
<td>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</td>
</tr>
<tr>
<td>[options.instanceMethods]</td>
<td>Object</td>
<td>Provide functions that are added to each instance (DAO)</td>
</tr>
<tr>
<td>[options.classMethods]</td>
<td>Object</td>
<td>Provide functions that are added to the model (DAOFactory)</td>
</tr>
<tr>
<td>[options.schema='public']</td>
<td>String</td>
<td></td>
</tr>
<tr>
<td>[options.engine]</td>
<td>String</td>
<td></td>
</tr>
<tr>
<td>[options.charset]</td>
<td>Strng</td>
<td></td>
</tr>
<tr>
<td>[options.comment]</td>
<td>String</td>
<td></td>
</tr>
<tr>
<td>[options.collate]</td>
<td>String</td>
<td></td>
</tr>
</table>
#### Return:
* **DaoFactory**
------
<a name="model" />
### model(daoName)
Fetch a DAO factory
Fetch a DAO factory which is already defined
#### Params:
<table>
......@@ -253,17 +586,75 @@ Fetch a DAO factory
</table>
#### Return:
* **DAOFactory** The DAOFactory for daoName
------
<a name="isDefined" />
### isDefined(daoName)
Checks whether a DAO with the given name is defined
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>daoName</td>
<td>String</td>
<td>The name of a model defined with Sequelize.define</td>
</tr>
</table>
#### Return:
* **Boolean** Is a DAO with that name already defined?
------
<a name="import" />
### import(path)
Imports a DAO defined in another file
Imported DAOs are cached, so multiple calls to import with the same path will not load the file multiple times
See https://github.com/sequelize/sequelize/blob/master/examples/using-multiple-model-files/Task.js for a short example of how to define your models in separate files so that they can be imported by sequelize.import
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>path</td>
<td>String</td>
<td>The path to the file that holds the model you want to import. If the part is relative, it will be resolved relatively to the calling file</td>
</tr>
</table>
#### Return:
* **DAOFactory**
------
<a name="query" />
### query(sql, [callee], [options={}], [replacements])
Execute a query on the DB, with the posibility to bypass all the sequelize goodness.
See {@link MyClass} and [MyClass's foo property]{@link MyClass#foo}.
Also, check out {@link http://www.google.com|Google} and
{@link https://github.com GitHub}.
See: {DAOFactory#build} for more information about callee.
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-DAOFactory#build"> for more information about callee.</a>
#### Params:
<table>
......@@ -286,7 +677,25 @@ See: {DAOFactory#build} for more information about callee.
<tr>
<td>[options={}]</td>
<td>Object</td>
<td>Query options. See above for a full set of options</td>
<td>Query options.</td>
</tr>
<tr>
<td>[options.raw]</td>
<td>Boolean</td>
<td>If true, sequelize will not try to format the results of the query, or build an instance of a model from the result</td>
</tr>
<tr>
<td>[options.type]</td>
<td>String</td>
<td>What is the type of this query (SELECT, UPDATE etc.). If the query starts with SELECT, the type will be assumed to be SELECT, otherwise no assumptions are made. Only used when raw is false. </td>
</tr>
<tr>
<td>[options.transaction=null]</td>
<td>Transaction</td>
<td>The transaction that the query should be executed under</td>
</tr>
<tr>
......@@ -297,8 +706,14 @@ See: {DAOFactory#build} for more information about callee.
</table>
#### Return:
* **EventEmitter**
------
<a name="query" />
### query(sql, [options={raw:true}])
Execute a raw query against the DB.
......@@ -323,11 +738,17 @@ Execute a raw query against the DB.
</table>
#### Return:
* **EventEmitter**
------
### authenticate(cake, a)
<a name="createSchema" />
Test the connetion by trying to authenticate
### createSchema(schema)
Create a new database schema
#### Params:
<table>
......@@ -336,25 +757,134 @@ Test the connetion by trying to authenticate
</thead>
<tr>
<td>cake</td>
<td>boolean</td>
<td>want cake?</td>
<td>schema</td>
<td>String</td>
<td>Name of the schema</td>
</tr>
</table>
#### Return:
* **EventEmitter**
------
<a name="showAllSchemas" />
### showAllSchemas()
Show all defined schemas
#### Return:
* **EventEmitter**
------
<a name="dropSchema" />
### dropSchema(schema)
Drop a single schema
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>a</td>
<td>string</td>
<td>something else</td>
<td>schema</td>
<td>String</td>
<td>Name of the schema</td>
</tr>
</table>
#### Return:
* **EventEmitter**
------
### authenticate (k)
<a name="dropAllSchemas" />
### dropAllSchemas()
Drop all schemas
#### Return:
* **EventEmitter**
------
<a name="sync" />
### sync([options={}])
Sync all defined DAOs to the DB.
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>[options={}]</td>
<td>Object</td>
<td></td>
</tr>
<tr>
<td>[options.force=false]</td>
<td>Boolean</td>
<td>If force is true, each DAO will do DROP TABLE IF EXISTS ..., before it tries to create its own table</td>
</tr>
<tr>
<td>[options.logging=console.log]</td>
<td>Boolean|function</td>
<td>A function that logs sql queries, or false for no logging</td>
</tr>
<tr>
<td>[options.schema='public']</td>
<td>String</td>
<td>The schema that the tables should be created in. This can be overriden for each table in sequelize.define</td>
</tr>
</table>
#### Return:
* **EventEmitter**
------
<a name="authenticate" />
### authenticate()
Test the connetion by trying to authenticate
#### Return:
* **EventEmitter**
------
<a name="fn" />
### fn(fn, args)
Creates a 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: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-Sequelize#col">Sequelize#col</a>
#### Params:
<table>
<thead>
......@@ -362,14 +892,224 @@ Test the connetion by trying to authenticate
</thead>
<tr>
<td>k</td>
<td>string</td>
<td>something else</td>
<td>fn</td>
<td>String</td>
<td>The function you want to call</td>
</tr>
<tr>
<td>args</td>
<td>any</td>
<td>All further arguments will be passed as arguments to the function</td>
</tr>
</table>
#### Return:
* **An** instance of Sequelize.fn
------
<!-- End ./lib/sequelize.js -->
<a name="col" />
### col(col)
Creates a object representing a column in the DB. This is usefull in sequelize.fn, since raw string arguments to that will be escaped.
See: Sequelize#fn
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>col</td>
<td>String</td>
<td>The name of the column</td>
</tr>
</table>
#### Return:
* **An** instance of Sequelize.col
------
<a name="cast" />
### cast(val, type)
Creates a object representing a call to the cast function.
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>val</td>
<td>any</td>
<td>The value to cast</td>
</tr>
<tr>
<td>type</td>
<td>String</td>
<td>The type to cast it to</td>
</tr>
</table>
#### Return:
* **An** instance of Sequelize.cast
------
<a name="literal" />
### literal(val)
Creates a object representing a literal, i.e. something that will not be escaped.
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>val</td>
<td>any</td>
<td></td>
</tr>
</table>
#### Return:
* **An** instance of Sequelize.literal
------
<a name="asIs" />
### asIs()
An alias of literal
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-Sequelize#literal">Sequelize#literal</a>
------
<a name="and" />
### and(args)
An AND query
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-DAOFactory#find">DAOFactory#find</a>
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>args</td>
<td>String|Object</td>
<td>Each argument will be joined by AND</td>
</tr>
</table>
#### Return:
* **An** instance of Sequelize.and
------
<a name="or" />
### or(args)
An OR query
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-DAOFactory#find">DAOFactory#find</a>
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>args</td>
<td>String|Object</td>
<td>Each argument will be joined by OR</td>
</tr>
</table>
#### Return:
* **An** instance of Sequelize.or
------
<a name="transaction" />
### transaction([options={}], callback)
Start a transaction.
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-Transaction"> </a>
#### Params:
<table>
<thead>
<th>Name</th><th>Type</th><th>Description</th>
</thead>
<tr>
<td>[options={}]</td>
<td>Object</td>
<td></td>
</tr>
<tr>
<td>[options.autocommit=true]</td>
<td>Boolean</td>
<td></td>
</tr>
<tr>
<td>[options.isolationLevel='REPEATABLE_READ']</td>
<td>String</td>
<td>One of READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE. It is preferred to use sequelize.Transaction.ISOLATION_LEVELS as opposed to providing a string</td>
</tr>
<tr>
<td>callback</td>
<td>Function</td>
<td>Called when the transaction has been set up and is ready for use. If the callback takes two arguments it will be called with err, transaction, otherwise it will be called with transaction.</td>
</tr>
</table>
#### Return:
* **Transaction**
------
_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 documentation was automagically created on Sun Feb 09 2014 20:14:56 GMT+0100 (CET)_
<? docfiles.forEach(function(doc) { ?>
<!-- Start <?= doc.filename ?> -->
<? doc.javadoc.forEach(function(comment) { ?>
<? if (comment.name) { ?>
<? if (comment.name) { ?>
<? if (!comment.ignore) { ?>
<? if (comment.isConstructor) { ?>
## new <?= comment.name ?>()
<? } else if (comment.isMethod || comment.isFunction) { ?>
### <?= comment.name ?>(<?= comment.paramStr ?>)
<? } else { ?>
### <?= comment.name ?>
<a name="<?= comment.name ?>" />
<? if (comment.isConstructor) { ?>
## new <?= comment.name ?>(<?= comment.paramStr ?>)
<? } else if (comment.isMethod || comment.isFunction) { ?>
### <?= comment.name ?>(<?= comment.paramStr ?>)
<? } else { ?>
### <?= comment.name ?>
<? } ?>
<? } ?>
<? } ?>
<?= comment.description ?>
<? if (comment.isClass) { ?>
### Members:
<? doc.members.forEach(function (member) { ?>
* <a href="#<?= member ?>"><?= member ?></a><? }) ?>
<? } ?>
<? if (comment.deprecated) { ?>
**Deprecated**
<? } ?>
......@@ -29,7 +33,15 @@
<? } ?>
<? if (comment.see) { ?>
See: <?= comment.see ?>
<? if (comment.seeURL !== false) { ?>
<? if (comment.seeExternal) { ?>
See: <a href="<?= comment.seeURL ?>"><?= comment.seeText ?></a>
<? } else { ?>
See: <a href="https://github.com/sequelize/sequelize/wiki/API-Reference-<?= comment.seeURL ?>"><?= comment.seeText ?></a>
<? } ?>
<? } else { ?>
See: <?= comment.see ?>
<? } ?>
<? } ?>
<? if (comment.paramTags.length > 0) { ?>
......@@ -58,6 +70,8 @@
------
<? }) ?>
<!-- End <?= doc.filename ?> -->
_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 documentation was automagically created on <?= new Date().toString() ?>_
<? }) ?>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!