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

Commit e417e0a8 by Sascha Depold

some documentation

1 parent f13e4e97
...@@ -103,13 +103,108 @@ ...@@ -103,13 +103,108 @@
"name": "password", "name": "password",
"description": "The password which is used to authenticate against the database.", "description": "The password which is used to authenticate against the database.",
"type": "String", "type": "String",
"optional": true "optional": true,
"optdefault": "null"
}, },
{ {
"name": "options", "name": "options",
"description": "An object with options.", "description": "An object with options.",
"type": "Object", "type": "Object",
"optional": true "optional": true,
"optdefault": "{}",
"props": [
{
"name": "dialect",
"description": "The dialect of the relational database.",
"type": "String",
"optional": true,
"optdefault": "'mysql'"
},
{
"name": "host",
"description": "The host of the relational database.",
"type": "String",
"optional": true,
"optdefault": "'localhost'"
},
{
"name": "port",
"description": "The port of the relational database.",
"type": "Integer",
"optional": true,
"optdefault": "3306"
},
{
"name": "protocol",
"description": "The protocol of the relational database.",
"type": "String",
"optional": true,
"optdefault": "'tcp'"
},
{
"name": "define",
"description": "Options, which shall be default for every model definition.",
"type": "Object",
"optional": true,
"optdefault": "{}"
},
{
"name": "query",
"description": "I have absolutely no idea.",
"type": "Object",
"optional": true,
"optdefault": "{}"
},
{
"name": "sync",
"description": "Options, which shall be default for every `sync` call.",
"type": "Object",
"optional": true,
"optdefault": "{}"
},
{
"name": "logging",
"description": "A function that gets executed everytime Sequelize would log something.",
"type": "Function",
"optional": true,
"optdefault": "console.log"
},
{
"name": "omitNull",
"description": "A flag that defines if null values should be passed to SQL queries or not.",
"type": "Boolean",
"optional": true,
"optdefault": "false"
},
{
"name": "queue",
"description": "I have absolutely no idea.",
"type": "Boolean",
"optional": true,
"optdefault": "true"
},
{
"name": "native",
"description": "A flag that defines if native library shall be used or not.",
"type": "Boolean",
"optional": true,
"optdefault": "false"
},
{
"name": "replication",
"description": "I have absolutely no idea.",
"type": "Boolean",
"optional": true,
"optdefault": "false"
},
{
"name": "pool",
"description": "Something.",
"type": "Object",
"optional": true,
"optdefault": "{}"
}
]
} }
], ],
"example": [ "example": [
...@@ -359,9 +454,49 @@ ...@@ -359,9 +454,49 @@
}, },
{ {
"file": "lib/sequelize.js", "file": "lib/sequelize.js",
"line": 80, "line": 93,
"description": "Reference to Utils", "description": "Reference to Utils",
"class": "Sequelize" "class": "Sequelize"
},
{
"file": "lib/sequelize.js",
"line": 102,
"description": "Returns an instance of QueryInterface.",
"itemtype": "method",
"name": "getQueryInterface",
"return": {
"description": "An instance (singleton) of QueryInterface.",
"type": "QueryInterface"
},
"class": "Sequelize"
},
{
"file": "lib/sequelize.js",
"line": 113,
"description": "Returns an instance (singleton) of Migrator.",
"itemtype": "method",
"name": "getMigrator",
"params": [
{
"name": "options",
"description": "Some options",
"type": "Object",
"optional": true,
"optdefault": "{}"
},
{
"name": "force",
"description": "A flag that defines if the migrator should get instantiated or not.",
"type": "Boolean",
"optional": true,
"optdefault": "false"
}
],
"return": {
"description": "An instance of Migrator.",
"type": "Migrator"
},
"class": "Sequelize"
} }
], ],
"warnings": [ "warnings": [
...@@ -419,7 +554,7 @@ ...@@ -419,7 +554,7 @@
}, },
{ {
"message": "Missing item type\nReference to Utils", "message": "Missing item type\nReference to Utils",
"line": " lib/sequelize.js:80" "line": " lib/sequelize.js:93"
} }
] ]
} }
\ No newline at end of file
...@@ -106,8 +106,21 @@ module.exports = (function() { ...@@ -106,8 +106,21 @@ module.exports = (function() {
@param {String} database The name of the database. @param {String} database The name of the database.
@param {String} username The username which is used to authenticate against the database. @param {String} username The username which is used to authenticate against the database.
@param {String} [password] The password which is used to authenticate against the database. @param {String} [password=null] The password which is used to authenticate against the database.
@param {Object} [options] An object with options. @param {Object} [options={}] An object with options.
@param {String} [options.dialect='mysql'] The dialect of the relational database.
@param {String} [options.host='localhost'] The host of the relational database.
@param {Integer} [options.port=3306] 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.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.
@param {Boolean} [options.omitNull=false] A flag that defines if null values should be passed to SQL queries or not.
@param {Boolean} [options.queue=true] I have absolutely no idea.
@param {Boolean} [options.native=false] A flag that defines if native library shall be used or not.
@param {Boolean} [options.replication=false] I have absolutely no idea.
@param {Object} [options.pool={}] Something.
@example @example
// without password and options // without password and options
...@@ -178,13 +191,28 @@ module.exports = (function() { ...@@ -178,13 +191,28 @@ module.exports = (function() {
Sequelize[dataType] = DataTypes[dataType] Sequelize[dataType] = DataTypes[dataType]
} }
/**
Returns an instance of QueryInterface.
@method getQueryInterface
@return {QueryInterface} An instance (singleton) of QueryInterface.
*/
Sequelize.prototype.getQueryInterface = function() { Sequelize.prototype.getQueryInterface = function() {
this.queryInterface = this.queryInterface || new QueryInterface(this) this.queryInterface = this.queryInterface || new QueryInterface(this)
return this.queryInterface return this.queryInterface
} }
/**
Returns an instance (singleton) of Migrator.
@method getMigrator
@param {Object} [options={}] Some options
@param {Boolean} [force=false] A flag that defines if the migrator should get instantiated or not.
@return {Migrator} An instance of Migrator.
*/
Sequelize.prototype.getMigrator = function(options, force) { Sequelize.prototype.getMigrator = function(options, force) {
var Migrator = require("./migrator") var Migrator = require("./migrator")
if (force) { if (force) {
this.migrator = new Migrator(this, options) this.migrator = new Migrator(this, options)
} else { } else {
...@@ -232,10 +260,9 @@ module.exports = (function() { ...@@ -232,10 +260,9 @@ module.exports = (function() {
this.getMigrator().migrate(options) this.getMigrator().migrate(options)
} }
Sequelize.prototype.query = function(sql, callee, options) { Sequelize.prototype.query = function(sql, callee, options, replacements) {
if (arguments.length === 4) { if (arguments.length === 4) {
values.unshift(sql) sql = Utils.format([sql].concat(replacements))
sql = Utils.format(values)
} else if (arguments.length === 3) { } else if (arguments.length === 3) {
options = options options = options
} else if (arguments.length === 2) { } else if (arguments.length === 2) {
......
...@@ -14,8 +14,21 @@ module.exports = (function() { ...@@ -14,8 +14,21 @@ module.exports = (function() {
@param {String} database The name of the database. @param {String} database The name of the database.
@param {String} username The username which is used to authenticate against the database. @param {String} username The username which is used to authenticate against the database.
@param {String} [password] The password which is used to authenticate against the database. @param {String} [password=null] The password which is used to authenticate against the database.
@param {Object} [options] An object with options. @param {Object} [options={}] An object with options.
@param {String} [options.dialect='mysql'] The dialect of the relational database.
@param {String} [options.host='localhost'] The host of the relational database.
@param {Integer} [options.port=3306] 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.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.
@param {Boolean} [options.omitNull=false] A flag that defines if null values should be passed to SQL queries or not.
@param {Boolean} [options.queue=true] I have absolutely no idea.
@param {Boolean} [options.native=false] A flag that defines if native library shall be used or not.
@param {Boolean} [options.replication=false] I have absolutely no idea.
@param {Object} [options.pool={}] Something.
@example @example
// without password and options // without password and options
...@@ -86,13 +99,28 @@ module.exports = (function() { ...@@ -86,13 +99,28 @@ module.exports = (function() {
Sequelize[dataType] = DataTypes[dataType] Sequelize[dataType] = DataTypes[dataType]
} }
/**
Returns an instance of QueryInterface.
@method getQueryInterface
@return {QueryInterface} An instance (singleton) of QueryInterface.
*/
Sequelize.prototype.getQueryInterface = function() { Sequelize.prototype.getQueryInterface = function() {
this.queryInterface = this.queryInterface || new QueryInterface(this) this.queryInterface = this.queryInterface || new QueryInterface(this)
return this.queryInterface return this.queryInterface
} }
/**
Returns an instance (singleton) of Migrator.
@method getMigrator
@param {Object} [options={}] Some options
@param {Boolean} [force=false] A flag that defines if the migrator should get instantiated or not.
@return {Migrator} An instance of Migrator.
*/
Sequelize.prototype.getMigrator = function(options, force) { Sequelize.prototype.getMigrator = function(options, force) {
var Migrator = require("./migrator") var Migrator = require("./migrator")
if (force) { if (force) {
this.migrator = new Migrator(this, options) this.migrator = new Migrator(this, options)
} else { } else {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!