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 26d71630
authored
Mar 28, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
define method + constructor + data-type mixin
1 parent
05a1faa9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
lib/sequelize/Sequelize.js
lib/sequelize/Sequelize.js
View file @
26d7163
var
Utils
=
require
(
"./utils"
)
,
Model
=
require
(
"./model"
)
var
Sequelize
=
module
.
exports
=
function
(
database
,
username
,
password
,
options
)
{
options
=
options
||
{}
var
ModelManager
=
require
(
"./model-manager"
)
this
.
modelManager
=
new
ModelManager
()
this
.
options
=
Utils
.
_
.
reject
(
options
,
function
(
value
,
key
)
{
return
[
"host"
,
"port"
,
"disableTableNameModification"
].
indexOf
(
key
)
>
-
1
})
this
.
config
=
{
database
:
database
,
username
:
username
,
password
:
((
([
""
,
null
,
false
].
indexOf
(
password
)
>
-
1
)
||
(
typeof
password
==
'undefined'
))
?
null
:
password
),
host
:
options
.
host
||
'localhost'
,
port
:
options
.
port
||
3306
}
}
var
instanceMethods
=
{
define
:
function
(
modelName
,
attributes
,
options
)
{
options
=
options
||
{}
var
model
=
this
.
modelManager
.
addModel
(
new
Model
(
modelName
,
attributes
,
options
))
return
model
}
}
Utils
.
_
.
map
(
require
(
'./data-types'
),
function
(
sql
,
accessor
)
{
Sequelize
[
accessor
]
=
sql
})
Utils
.
_
.
map
(
instanceMethods
,
function
(
fct
,
name
)
{
Sequelize
.
prototype
[
name
]
=
fct
})
\ No newline at end of file
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