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 0152354c
authored
Mar 28, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cross connect model, model manager and sequelize
1 parent
d0162c9d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
lib/sequelize/Sequelize.js
lib/sequelize/model-manager.js
lib/sequelize/model.js
lib/sequelize/Sequelize.js
View file @
0152354
...
...
@@ -5,7 +5,7 @@ var Sequelize = module.exports = function(database, username, password, options)
options
=
options
||
{}
var
ModelManager
=
require
(
"./model-manager"
)
this
.
modelManager
=
new
ModelManager
()
this
.
modelManager
=
new
ModelManager
(
this
)
this
.
options
=
Utils
.
_
.
reject
(
options
,
function
(
value
,
key
)
{
return
[
"host"
,
"port"
,
"disableTableNameModification"
].
indexOf
(
key
)
>
-
1
})
this
.
config
=
{
database
:
database
,
...
...
@@ -23,6 +23,20 @@ var instanceMethods = {
var
model
=
this
.
modelManager
.
addModel
(
new
Model
(
modelName
,
attributes
,
options
))
return
model
},
query
:
function
(
sql
,
callback
)
{
var
client
=
new
(
require
(
"mysql"
).
client
)({
user
:
this
.
username
,
password
:
this
.
password
,
host
:
this
.
config
.
host
,
port
:
this
.
config
.
port
,
database
:
this
.
config
.
database
})
client
.
connect
()
client
.
query
(
sql
)
client
.
end
()
}
}
...
...
lib/sequelize/model-manager.js
View file @
0152354
var
ModelManager
=
module
.
exports
=
function
()
{
var
ModelManager
=
module
.
exports
=
function
(
sequelize
)
{
this
.
models
=
[]
this
.
sequelize
=
sequelize
}
ModelManager
.
prototype
.
addModel
=
function
(
model
)
{
model
.
modelManager
=
this
this
.
models
.
push
(
model
)
return
model
}
...
...
lib/sequelize/model.js
View file @
0152354
...
...
@@ -14,6 +14,7 @@ var Model = module.exports = function(name, attributes, options) {
this
.
attributes
=
attributes
this
.
options
=
options
||
{}
this
.
modelManager
=
null
// defined by model-manager during addModel
this
.
associations
=
[]
}
...
...
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