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 63d2aa6a
authored
Sep 08, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed assoc getters to get*
1 parent
cb72b05e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
lib/sequelize/SequelizeTable.js
test/SequelizeTableTest.js
lib/sequelize/SequelizeTable.js
View file @
63d2aa6
...
...
@@ -163,7 +163,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
type
:
'hasOne'
})
table
.
prototype
[
assocName
]
=
function
(
callback
)
{
table
.
prototype
[
Sequelize
.
Helper
.
SQL
.
addPrefix
(
'get'
,
assocName
)
]
=
function
(
callback
)
{
var
whereConditions
=
{}
whereConditions
[
table
.
identifier
]
=
this
.
id
_table
.
find
(
whereConditions
,
callback
)
...
...
@@ -172,7 +172,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
table
.
prototype
[
Sequelize
.
Helper
.
SQL
.
addPrefix
(
'set'
,
assocName
)]
=
function
(
object
,
callback
)
{
var
self
=
this
this
[
assocName
](
function
(
currentAssociation
)
{
this
[
Sequelize
.
Helper
.
SQL
.
addPrefix
(
'get'
,
assocName
)
](
function
(
currentAssociation
)
{
var
attr
=
{}
if
(
currentAssociation
==
null
)
{
attr
[
table
.
identifier
]
=
self
.
id
...
...
@@ -200,7 +200,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
type
:
'belongsTo'
})
table
.
prototype
[
assocName
]
=
function
(
callback
)
{
table
.
prototype
[
Sequelize
.
Helper
.
SQL
.
addPrefix
(
'get'
,
assocName
)
]
=
function
(
callback
)
{
if
((
this
[
_table
.
identifier
]
==
null
)
||
(
isNaN
(
this
[
_table
.
identifier
])))
callback
([])
else
...
...
@@ -211,7 +211,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
var
attr
=
{};
attr
[
object
.
table
.
identifier
]
=
object
.
id
var
self
=
this
this
.
updateAttributes
(
attr
,
function
()
{
self
[
assocName
](
callback
)
self
[
Sequelize
.
Helper
.
SQL
.
addPrefix
(
'get'
,
assocName
)
](
callback
)
})
}
...
...
test/SequelizeTableTest.js
View file @
63d2aa6
...
...
@@ -134,7 +134,7 @@ module.exports = {
'hasMany'
:
function
(
assert
)
{
var
HasManyBlubb
=
s
.
define
(
'HasManyBlubb'
,
{})
Day
.
hasMany
(
'HasManyBlubbs'
,
HasManyBlubb
)
assert
.
isDefined
(
new
Day
({
name
:
''
}).
HasManyBlubbs
)
assert
.
isDefined
(
new
Day
({
name
:
''
}).
get
HasManyBlubbs
)
},
'hasMany: set association'
:
function
(
assert
,
beforeExit
)
{
var
assoc
=
null
...
...
@@ -169,7 +169,7 @@ module.exports = {
var
Day
=
s
.
define
(
'Day2'
,
{
name
:
Sequelize
.
TEXT
})
var
HasOneBlubb
=
s
.
define
(
'HasOneBlubb'
,
{})
Day
.
hasOne
(
'HasOneBlubb'
,
HasOneBlubb
)
assert
.
isDefined
(
new
Day
({
name
:
''
}).
HasOneBlubb
)
assert
.
isDefined
(
new
Day
({
name
:
''
}).
get
HasOneBlubb
)
},
'hasOne set association'
:
function
(
assert
,
beforeExit
)
{
var
s2
=
new
Sequelize
(
'sequelize_test'
,
'test'
,
'test'
,
{
disableLogging
:
true
})
...
...
@@ -197,7 +197,7 @@ module.exports = {
'belongsTo'
:
function
(
assert
)
{
var
BelongsToBlubb
=
s
.
define
(
'BelongsToBlubb'
,
{})
Day
.
belongsTo
(
'BelongsToBlubb'
,
BelongsToBlubb
)
assert
.
isDefined
(
new
Day
({
name
:
''
}).
BelongsToBlubb
)
assert
.
isDefined
(
new
Day
({
name
:
''
}).
get
BelongsToBlubb
)
},
'belongsTo: set association'
:
function
(
assert
,
beforeExit
)
{
var
s2
=
new
Sequelize
(
'sequelize_test'
,
'test'
,
'test'
,
{
disableLogging
:
true
})
...
...
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