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 28ac7564
authored
Nov 09, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chainable associations
1 parent
5a73894c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletions
changelog.md
lib/associations/mixin.js
changelog.md
View file @
28ac756
# v1.3.0 #
# v1.3.0 #
-
[
REFACTORING
]
Model#all is now a function and not a getter.
-
[
REFACTORING
]
Model#all is now a function and not a getter.
-
[
REFACTORING
]
Renamed ModelDefinition to ModelFactory
-
[
FEATURE
]
Association definition is chainable: Person.hasOne(House).hasMany(Address)
# v1.2.1 #
# v1.2.1 #
-
[
REFACTORING
]
renamed the global options for sync, query and define on sequelize; before: options.queryOptions; now: options.query
-
[
REFACTORING
]
renamed the global options for sync, query and define on sequelize; before: options.queryOptions; now: options.query
...
...
lib/associations/mixin.js
View file @
28ac756
...
@@ -8,18 +8,21 @@ Mixin.hasOne = function(associatedModel, options) {
...
@@ -8,18 +8,21 @@ Mixin.hasOne = function(associatedModel, options) {
var
HasOne
=
require
(
'./has-one'
)
var
HasOne
=
require
(
'./has-one'
)
var
association
=
new
HasOne
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
var
association
=
new
HasOne
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
return
this
}
}
Mixin
.
belongsTo
=
function
(
associatedModel
,
options
)
{
Mixin
.
belongsTo
=
function
(
associatedModel
,
options
)
{
// the id is in this table
// the id is in this table
var
BelongsTo
=
require
(
"./belongs-to"
)
var
BelongsTo
=
require
(
"./belongs-to"
)
var
association
=
new
BelongsTo
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
var
association
=
new
BelongsTo
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
return
this
}
}
Mixin
.
hasMany
=
function
(
associatedModel
,
options
)
{
Mixin
.
hasMany
=
function
(
associatedModel
,
options
)
{
// the id is in the foreign table or in a connecting table
// the id is in the foreign table or in a connecting table
var
HasMany
=
require
(
"./has-many"
)
var
HasMany
=
require
(
"./has-many"
)
var
association
=
new
HasMany
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
var
association
=
new
HasMany
(
this
,
associatedModel
,
Utils
.
_
.
extend
((
options
||
{}),
this
.
options
))
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
this
.
associations
[
association
.
associationAccessor
]
=
association
.
injectAttributes
()
return
this
}
}
/* example for instance methods:
/* example for instance methods:
...
...
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