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 3a6b4f55
authored
Sep 06, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use the assocname as table identifier
1 parent
354c88ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
lib/sequelize/SequelizeTable.js
lib/sequelize/SequelizeTable.js
View file @
3a6b4f5
...
@@ -46,26 +46,28 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
...
@@ -46,26 +46,28 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
prepareAssociations
:
function
(
callback
)
{
prepareAssociations
:
function
(
callback
)
{
table
.
associations
.
forEach
(
function
(
association
)
{
table
.
associations
.
forEach
(
function
(
association
)
{
var
assocNameAsTableIdentifier
=
Sequelize
.
Helper
.
SQL
.
asTableIdentifier
(
association
.
name
)
switch
(
association
.
type
)
{
switch
(
association
.
type
)
{
case
'hasMany'
:
case
'hasMany'
:
if
(
association
.
backAssociationName
)
{
if
(
association
.
backAssociationName
)
{
// many to many relation
// many to many relation
var
_attributes
=
{}
var
_attributes
=
{}
_attributes
[
Sequelize
.
Helper
.
SQL
.
asTableIdentifier
(
association
.
name
)
]
=
Sequelize
.
INTEGER
_attributes
[
assocNameAsTableIdentifier
]
=
Sequelize
.
INTEGER
_attributes
[
Sequelize
.
Helper
.
SQL
.
asTableIdentifier
(
association
.
backAssociationName
)]
=
Sequelize
.
INTEGER
_attributes
[
Sequelize
.
Helper
.
SQL
.
asTableIdentifier
(
association
.
backAssociationName
)]
=
Sequelize
.
INTEGER
sequelize
.
define
(
Sequelize
.
Helper
.
SQL
.
manyToManyTableName
(
association
.
name
,
association
.
backAssociationName
),
_attributes
)
sequelize
.
define
(
Sequelize
.
Helper
.
SQL
.
manyToManyTableName
(
association
.
name
,
association
.
backAssociationName
),
_attributes
)
}
else
{
}
else
{
// one to many relation
// one to many relation
association
.
table
.
attributes
[
table
.
i
dentifier
]
=
{
type
:
Sequelize
.
INTEGER
}
association
.
table
.
attributes
[
assocNameAsTableI
dentifier
]
=
{
type
:
Sequelize
.
INTEGER
}
}
}
break
break
case
'hasOne'
:
case
'hasOne'
:
// e.g. assocTable.myTableId = Sequelize.INTEGER
// e.g. assocTable.myTableId = Sequelize.INTEGER
association
.
table
.
attributes
[
table
.
i
dentifier
]
=
{
type
:
Sequelize
.
INTEGER
}
association
.
table
.
attributes
[
assocNameAsTableI
dentifier
]
=
{
type
:
Sequelize
.
INTEGER
}
break
break
case
'belongsTo'
:
case
'belongsTo'
:
// e.g. table.dayId = Sequelize.INTEGER
// e.g. table.dayId = Sequelize.INTEGER
table
.
attributes
[
assoc
iation
.
table
.
i
dentifier
]
=
{
type
:
Sequelize
.
INTEGER
}
table
.
attributes
[
assoc
NameAsTableI
dentifier
]
=
{
type
:
Sequelize
.
INTEGER
}
break
break
}
}
})
})
...
...
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