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 dcd24011
authored
Sep 29, 2012
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added isDefined for sequelize
1 parent
1d87f43b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
lib/sequelize.js
spec/sequelize.spec.js
lib/sequelize.js
View file @
dcd2401
...
@@ -65,18 +65,21 @@ module.exports = (function() {
...
@@ -65,18 +65,21 @@ module.exports = (function() {
Sequelize
.
prototype
.
define
=
function
(
daoName
,
attributes
,
options
)
{
Sequelize
.
prototype
.
define
=
function
(
daoName
,
attributes
,
options
)
{
options
=
options
||
{}
options
=
options
||
{}
if
(
this
.
options
.
define
)
{
if
(
this
.
options
.
define
)
options
=
Sequelize
.
Utils
.
merge
(
options
,
this
.
options
.
define
)
options
=
Sequelize
.
Utils
.
merge
(
options
,
this
.
options
.
define
)
}
options
.
omitNull
=
this
.
options
.
omitNull
options
.
omitNull
=
this
.
options
.
omitNull
var
factory
=
new
DAOFactory
(
daoName
,
attributes
,
options
)
var
factory
=
new
DAOFactory
(
daoName
,
attributes
,
options
)
this
.
daoFactoryManager
.
addDAO
(
factory
.
init
(
this
.
daoFactoryManager
))
this
.
daoFactoryManager
.
addDAO
(
factory
.
init
(
this
.
daoFactoryManager
))
return
factory
return
factory
}
}
Sequelize
.
prototype
.
isDefined
=
function
(
daoName
)
{
var
daos
=
this
.
daoFactoryManager
.
daos
return
(
daos
.
filter
(
function
(
dao
)
{
return
dao
.
name
===
daoName
}).
length
!==
0
)
}
Sequelize
.
prototype
.
import
=
function
(
path
)
{
Sequelize
.
prototype
.
import
=
function
(
path
)
{
if
(
!
this
.
importCache
[
path
])
{
if
(
!
this
.
importCache
[
path
])
{
var
defineCall
=
require
(
path
)
var
defineCall
=
require
(
path
)
...
...
spec/sequelize.spec.js
View file @
dcd2401
...
@@ -20,4 +20,17 @@ describe('Sequelize', function() {
...
@@ -20,4 +20,17 @@ describe('Sequelize', function() {
expect
(
1
).
toEqual
(
1
)
expect
(
1
).
toEqual
(
1
)
})
})
})
})
describe
(
'isDefined'
,
function
()
{
it
(
"returns false if the dao wasn't defined before"
,
function
()
{
expect
(
this
.
sequelize
.
isDefined
(
'Project'
)).
toBeFalse
()
})
it
(
"returns true if the dao was defined before"
,
function
()
{
this
.
sequelize
.
define
(
'Project'
,
{
name
:
Helpers
.
Sequelize
.
STRING
})
expect
(
this
.
sequelize
.
isDefined
(
'Project'
)).
toBeTrue
()
})
})
})
})
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