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 36c179e9
authored
Jan 07, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved require's out of functions and declared it at the top of the file
1 parent
76c5ac79
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
lib/associations/mixin.js
lib/associations/mixin.js
View file @
36c179e
var
Utils
=
require
(
"./../utils"
)
var
Utils
=
require
(
"./../utils"
)
,
HasOne
=
require
(
'./has-one'
)
,
HasMany
=
require
(
"./has-many"
)
,
BelongsTo
=
require
(
"./belongs-to"
)
/* Defines Mixin for all models. */
var
Mixin
=
module
.
exports
=
function
(){}
Mixin
.
hasOne
=
function
(
associatedModel
,
options
)
{
// the id is in the foreign table
var
HasOne
=
require
(
'./has-one'
)
var
association
=
new
HasOne
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
return
this
}
Mixin
.
belongsTo
=
function
(
associatedModel
,
options
)
{
// the id is in this table
var
BelongsTo
=
require
(
"./belongs-to"
)
var
association
=
new
BelongsTo
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
return
this
}
Mixin
.
hasMany
=
function
(
associatedModel
,
options
)
{
// the id is in the foreign table or in a connecting table
var
HasMany
=
require
(
"./has-many"
)
var
association
=
new
HasMany
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
return
this
...
...
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