Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 25d7d3cb
authored
Jun 01, 2015
by
overlookmotel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests hints for options shimming
1 parent
760eb59e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
11 deletions
lib/associations/mixin.js
lib/instance.js
lib/model.js
lib/query-interface.js
lib/sequelize.js
lib/associations/mixin.js
View file @
25d7d3c
...
...
@@ -97,7 +97,7 @@ var Mixin = module.exports = function() {};
// The logic for hasOne and belongsTo is exactly the same
var
singleLinked
=
function
(
Type
)
{
return
function
(
targetModel
,
options
)
{
return
function
(
targetModel
,
options
)
{
// testhint options:none
if
(
!
(
targetModel
instanceof
this
.
sequelize
.
Model
))
{
throw
new
Error
(
this
.
name
+
'.'
+
Utils
.
lowercaseFirst
(
Type
.
toString
())
+
' called with something that\'s not an instance of Sequelize.Model'
);
}
...
...
@@ -244,7 +244,7 @@ Mixin.belongsTo = singleLinked(BelongsTo);
* @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key.
*/
Mixin
.
hasMany
=
function
(
targetModel
,
options
)
{
Mixin
.
hasMany
=
function
(
targetModel
,
options
)
{
// testhint options:none
if
(
!
(
targetModel
instanceof
this
.
sequelize
.
Model
))
{
throw
new
Error
(
this
.
name
+
'.hasMany called with something that\'s not an instance of Sequelize.Model'
);
}
...
...
@@ -338,7 +338,7 @@ Mixin.hasMany = function(targetModel, options) {
* @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key.
*/
Mixin
.
belongsToMany
=
function
(
targetModel
,
options
)
{
Mixin
.
belongsToMany
=
function
(
targetModel
,
options
)
{
// testhint options:none
if
(
!
(
targetModel
instanceof
this
.
sequelize
.
Model
))
{
throw
new
Error
(
this
.
name
+
'.belongsToMany called with something that\'s not an instance of Sequelize.Model'
);
}
...
...
lib/instance.js
View file @
25d7d3c
...
...
@@ -176,7 +176,7 @@ Instance.prototype.setDataValue = function(key, value) {
* @param {Boolean} [options.plain=false] If set to true, included instances will be returned as plain objects
* @return {Object|any}
*/
Instance
.
prototype
.
get
=
function
(
key
,
options
)
{
Instance
.
prototype
.
get
=
function
(
key
,
options
)
{
// testhint options:none
if
(
options
===
undefined
&&
typeof
key
===
'object'
)
{
options
=
key
;
key
=
undefined
;
...
...
@@ -246,7 +246,7 @@ Instance.prototype.get = function(key, options) {
* @param {Boolean} [options.reset=false] Clear all previously set data values
* @alias setAttributes
*/
Instance
.
prototype
.
set
=
function
(
key
,
value
,
options
)
{
Instance
.
prototype
.
set
=
function
(
key
,
value
,
options
)
{
// testhint options:none
var
values
,
originalValue
,
keys
...
...
lib/model.js
View file @
25d7d3c
...
...
@@ -919,7 +919,7 @@ Model.prototype.dropSchema = function(schema) {
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @return {this}
*/
Model
.
prototype
.
schema
=
function
(
schema
,
options
)
{
Model
.
prototype
.
schema
=
function
(
schema
,
options
)
{
// testhint options:none
this
.
options
.
schema
=
schema
;
if
(
!!
options
)
{
...
...
@@ -943,7 +943,7 @@ Model.prototype.schema = function(schema, options) {
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @return {String|Object}
*/
Model
.
prototype
.
getTableName
=
function
(
options
)
{
Model
.
prototype
.
getTableName
=
function
(
options
)
{
// testhint options:none
return
this
.
QueryGenerator
.
addSchema
(
this
);
};
...
...
@@ -1394,7 +1394,7 @@ Model.prototype.count = function(options) {
* @return {Promise<Object>}
* @alias findAndCountAll
*/
Model
.
prototype
.
findAndCount
=
function
(
findOptions
)
{
Model
.
prototype
.
findAndCount
=
function
(
findOptions
)
{
// testhint options:1
if
(
findOptions
!==
undefined
&&
!
_
.
isPlainObject
(
findOptions
))
{
throw
new
Error
(
'The argument passed to findAndCount must be an options object, use findById if you wish to pass a single primary key value'
);
}
...
...
@@ -1499,7 +1499,7 @@ Model.prototype.sum = function(field, options) {
*
* @return {Instance}
*/
Model
.
prototype
.
build
=
function
(
values
,
options
)
{
Model
.
prototype
.
build
=
function
(
values
,
options
)
{
// testhint options:none
if
(
Array
.
isArray
(
values
))
{
return
this
.
bulkBuild
(
values
,
options
);
}
...
...
@@ -1525,7 +1525,7 @@ Model.prototype.build = function(values, options) {
};
Model
.
prototype
.
bulkBuild
=
function
(
valueSets
,
options
)
{
Model
.
prototype
.
bulkBuild
=
function
(
valueSets
,
options
)
{
// testhint options:none
options
=
_
.
extend
({
isNewRecord
:
true
},
options
||
{});
...
...
lib/query-interface.js
View file @
25d7d3c
...
...
@@ -437,6 +437,7 @@ QueryInterface.prototype.addIndex = function(tableName, attributes, options, raw
options
=
attributes
;
attributes
=
options
.
fields
;
}
// testhint argsConform.end
if
(
!
rawTablename
)
{
// Map for backwards compat
...
...
lib/sequelize.js
View file @
25d7d3c
...
...
@@ -511,7 +511,7 @@ Sequelize.prototype.getQueryInterface = function() {
*
* @return {Model}
*/
Sequelize
.
prototype
.
define
=
function
(
modelName
,
attributes
,
options
)
{
Sequelize
.
prototype
.
define
=
function
(
modelName
,
attributes
,
options
)
{
// testhint options:none
options
=
options
||
{};
var
globalOptions
=
this
.
options
;
...
...
@@ -1123,6 +1123,7 @@ Sequelize.prototype.transaction = function(options, autoCallback) {
autoCallback
=
options
;
options
=
undefined
;
}
// testhint argsConform.end
var
transaction
=
new
Transaction
(
this
,
options
)
,
ns
=
Sequelize
.
cls
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment