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 d863a5fd
authored
Oct 02, 2012
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save the type of the association
1 parent
66ccb75e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
lib/associations/belongs-to.js
lib/associations/has-one.js
lib/associations/belongs-to.js
View file @
d863a5f
...
@@ -3,13 +3,15 @@ var Utils = require("./../utils")
...
@@ -3,13 +3,15 @@ var Utils = require("./../utils")
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
BelongsTo
=
function
(
srcDAO
,
targetDAO
,
options
)
{
var
BelongsTo
=
function
(
srcDAO
,
targetDAO
,
options
)
{
this
.
source
=
srcDAO
this
.
associationType
=
'BelongsTo'
this
.
target
=
targetDAO
this
.
source
=
srcDAO
this
.
options
=
options
this
.
target
=
targetDAO
this
.
options
=
options
this
.
isSelfAssociation
=
(
this
.
source
.
tableName
==
this
.
target
.
tableName
)
this
.
isSelfAssociation
=
(
this
.
source
.
tableName
==
this
.
target
.
tableName
)
if
(
this
.
isSelfAssociation
&&
!
this
.
options
.
foreignKey
&&
!!
this
.
options
.
as
)
if
(
this
.
isSelfAssociation
&&
!
this
.
options
.
foreignKey
&&
!!
this
.
options
.
as
)
{
this
.
options
.
foreignKey
=
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
options
.
as
)
+
"Id"
,
this
.
source
.
options
.
underscored
)
this
.
options
.
foreignKey
=
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
options
.
as
)
+
"Id"
,
this
.
source
.
options
.
underscored
)
}
this
.
associationAccessor
=
this
.
isSelfAssociation
this
.
associationAccessor
=
this
.
isSelfAssociation
?
Utils
.
combineTableNames
(
this
.
target
.
tableName
,
this
.
options
.
as
||
this
.
target
.
tableName
)
?
Utils
.
combineTableNames
(
this
.
target
.
tableName
,
this
.
options
.
as
||
this
.
target
.
tableName
)
...
...
lib/associations/has-one.js
View file @
d863a5f
...
@@ -3,13 +3,15 @@ var Utils = require("./../utils")
...
@@ -3,13 +3,15 @@ var Utils = require("./../utils")
module
.
exports
=
(
function
()
{
module
.
exports
=
(
function
()
{
var
HasOne
=
function
(
srcDAO
,
targetDAO
,
options
)
{
var
HasOne
=
function
(
srcDAO
,
targetDAO
,
options
)
{
this
.
source
=
srcDAO
this
.
associationType
=
'HasOne'
this
.
target
=
targetDAO
this
.
source
=
srcDAO
this
.
options
=
options
this
.
target
=
targetDAO
this
.
options
=
options
this
.
isSelfAssociation
=
(
this
.
source
.
tableName
==
this
.
target
.
tableName
)
this
.
isSelfAssociation
=
(
this
.
source
.
tableName
==
this
.
target
.
tableName
)
if
(
this
.
isSelfAssociation
&&
!
this
.
options
.
foreignKey
&&
!!
this
.
options
.
as
)
if
(
this
.
isSelfAssociation
&&
!
this
.
options
.
foreignKey
&&
!!
this
.
options
.
as
)
{
this
.
options
.
foreignKey
=
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
options
.
as
)
+
"Id"
,
this
.
options
.
underscored
)
this
.
options
.
foreignKey
=
Utils
.
_
.
underscoredIf
(
Utils
.
singularize
(
this
.
options
.
as
)
+
"Id"
,
this
.
options
.
underscored
)
}
this
.
associationAccessor
=
this
.
isSelfAssociation
this
.
associationAccessor
=
this
.
isSelfAssociation
?
Utils
.
combineTableNames
(
this
.
target
.
tableName
,
this
.
options
.
as
||
this
.
target
.
tableName
)
?
Utils
.
combineTableNames
(
this
.
target
.
tableName
,
this
.
options
.
as
||
this
.
target
.
tableName
)
...
...
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