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 5df944e4
authored
Apr 26, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import function for sequelize
1 parent
a8feb36b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
1 deletions
lib/sequelize/sequelize.js
test/Sequelize/import.js
test/project.js
lib/sequelize/sequelize.js
View file @
5df944e
var
Utils
=
require
(
"./utils"
)
,
ModelDefinition
=
require
(
"./model-definition"
)
,
Query
=
require
(
"./query"
)
,
DataTypes
=
require
(
'./data-types'
)
var
Sequelize
=
module
.
exports
=
function
(
database
,
username
,
password
,
options
)
{
options
=
options
||
{}
...
...
@@ -30,6 +31,11 @@ var instanceMethods = {
return
model
},
import
:
function
(
path
)
{
var
defineCall
=
require
(
path
)
return
defineCall
(
this
,
DataTypes
)
},
query
:
function
(
sql
,
callee
,
options
)
{
options
=
options
||
{}
options
.
logging
=
this
.
options
.
hasOwnProperty
(
'logging'
)
?
this
.
options
.
logging
:
true
...
...
@@ -38,5 +44,5 @@ var instanceMethods = {
}
Sequelize
.
Utils
.
_
.
map
(
require
(
'./data-types'
)
,
function
(
sql
,
accessor
)
{
Sequelize
[
accessor
]
=
sql
})
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
test/Sequelize/import.js
0 → 100644
View file @
5df944e
var
assert
=
require
(
"assert"
)
,
config
=
require
(
"./../config"
)
,
Sequelize
=
require
(
"./../../index"
)
,
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
{
logging
:
false
})
module
.
exports
=
{
'the import should work correctly'
:
function
()
{
var
Project
=
sequelize
.
import
(
__dirname
+
"/../project"
)
assert
.
isDefined
(
Project
)
}
}
\ No newline at end of file
test/project.js
0 → 100644
View file @
5df944e
module
.
exports
=
function
(
sequelize
,
DataTypes
)
{
return
sequelize
.
define
(
'Project'
+
parseInt
(
Math
.
random
()
*
9999999999999999
),
{
name
:
DataTypes
.
STRING
})
}
\ 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