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 8cb6df21
authored
Jul 03, 2011
by
corpix
Committed by
Sascha Depold
Sep 01, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added global options for define, query, sync
1 parent
abdbc324
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
lib/sequelize/sequelize.js
lib/sequelize/utils.js
lib/sequelize/sequelize.js
View file @
8cb6df2
...
...
@@ -26,6 +26,8 @@ var instanceMethods = {
define
:
function
(
modelName
,
attributes
,
options
)
{
options
=
options
||
{}
if
(
this
.
options
.
defineOptions
)
options
=
Sequelize
.
Utils
.
merge
(
options
,
this
.
options
.
defineOptions
)
var
model
=
this
.
modelManager
.
addModel
(
new
ModelDefinition
(
modelName
,
attributes
,
options
))
return
model
...
...
@@ -38,11 +40,18 @@ var instanceMethods = {
query
:
function
(
sql
,
callee
,
options
)
{
options
=
options
||
{}
if
(
this
.
options
.
queryOptions
)
options
=
Sequelize
.
Utils
.
merge
(
options
,
this
.
options
.
queryOptions
)
options
.
logging
=
this
.
options
.
hasOwnProperty
(
'logging'
)
?
this
.
options
.
logging
:
true
return
new
Query
(
this
.
config
,
callee
,
options
).
run
(
sql
)
},
sync
:
function
(
options
)
{
options
=
options
||
{}
if
(
this
.
options
.
syncOptions
)
options
=
Sequelize
.
Utils
.
merge
(
options
,
this
.
options
.
syncOptions
)
var
self
=
this
var
eventEmitter
=
new
Utils
.
CustomEventEmitter
(
function
()
{
var
chainer
=
new
Utils
.
QueryChainer
...
...
@@ -60,4 +69,4 @@ var instanceMethods = {
Sequelize
.
Utils
.
_
.
map
(
DataTypes
,
function
(
sql
,
accessor
)
{
Sequelize
[
accessor
]
=
sql
})
Sequelize
.
Utils
.
_
.
map
(
instanceMethods
,
function
(
fct
,
name
)
{
Sequelize
.
prototype
[
name
]
=
fct
})
\ No newline at end of file
Sequelize
.
Utils
.
_
.
map
(
instanceMethods
,
function
(
fct
,
name
)
{
Sequelize
.
prototype
[
name
]
=
fct
})
lib/sequelize/utils.js
View file @
8cb6df2
...
...
@@ -137,6 +137,12 @@ var Utils = module.exports = {
},
pluralize
:
function
(
s
)
{
return
Utils
.
Lingo
.
en
.
isPlural
(
s
)
?
s
:
Utils
.
Lingo
.
en
.
pluralize
(
s
)
},
merge
:
function
(
a
,
b
){
for
(
var
key
in
b
)
{
a
[
key
]
=
b
[
key
]
}
return
a
}
}
...
...
@@ -153,4 +159,4 @@ CustomEventEmitter.prototype.run = function() {
}
Utils
.
QueryChainer
=
require
(
"./query-chainer"
)
Utils
.
Lingo
=
require
(
"lingo"
)
\ No newline at end of file
Utils
.
Lingo
=
require
(
"lingo"
)
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