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 66d899a7
authored
Sep 21, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
associatedData => fetchedAssociations
1 parent
cece3d69
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
examples/LoadAssociatedData/app.js
lib/sequelize/SequelizeTable.js
examples/LoadAssociatedData/app.js
View file @
66d899a
...
@@ -21,7 +21,7 @@ Sequelize.chainQueries([{drop: sequelize}, {sync: sequelize}], function() {
...
@@ -21,7 +21,7 @@ Sequelize.chainQueries([{drop: sequelize}, {sync: sequelize}], function() {
console
.
log
(
"Now let's get the same data with loadAssociatedData!"
)
console
.
log
(
"Now let's get the same data with loadAssociatedData!"
)
person
.
fetchAssociations
(
function
(
data
)
{
person
.
fetchAssociations
(
function
(
data
)
{
Sequelize
.
Helper
.
log
(
"And here we are: "
+
data
.
pets
[
0
].
name
)
Sequelize
.
Helper
.
log
(
"And here we are: "
+
data
.
pets
[
0
].
name
)
Sequelize
.
Helper
.
log
(
"The object should now also contain the data: "
+
person
.
associatedData
.
pets
[
0
].
name
)
Sequelize
.
Helper
.
log
(
"The object should now also contain the data: "
+
person
.
fetchedAssociations
.
pets
[
0
].
name
)
Person
.
find
(
person
.
id
,
{
fetchAssociations
:
true
},
function
(
p
)
{
Person
.
find
(
person
.
id
,
{
fetchAssociations
:
true
},
function
(
p
)
{
Sequelize
.
Helper
.
log
(
p
)
Sequelize
.
Helper
.
log
(
p
)
...
...
lib/sequelize/SequelizeTable.js
View file @
66d899a
...
@@ -36,6 +36,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
...
@@ -36,6 +36,7 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
this
.
id
=
null
// specify id as null to declare this object as unsaved and as not present in the database
this
.
id
=
null
// specify id as null to declare this object as unsaved and as not present in the database
this
.
table
=
table
this
.
table
=
table
this
.
fetchedAssociations
=
{}
}
}
// class methods
// class methods
...
@@ -304,8 +305,8 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
...
@@ -304,8 +305,8 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
var
associatedData
=
{},
var
associatedData
=
{},
self
=
this
,
self
=
this
,
setAssociatedDataAndReturn
=
function
()
{
setAssociatedDataAndReturn
=
function
()
{
self
.
associatedData
=
associatedData
self
.
fetchedAssociations
=
associatedData
if
(
callback
)
callback
(
associatedData
)
if
(
callback
)
callback
(
self
.
fetchedAssociations
)
}
}
if
(
this
.
table
.
associations
.
length
==
0
)
if
(
this
.
table
.
associations
.
length
==
0
)
...
@@ -323,6 +324,10 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
...
@@ -323,6 +324,10 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
})
})
},
},
hasFetchedAssociationFor
:
function
(
assocName
)
{
return
this
.
fetchedAssociations
&&
this
.
fetchedAssociations
[
assocName
]
},
save
:
function
(
callback
)
{
save
:
function
(
callback
)
{
var
query
=
null
,
var
query
=
null
,
self
=
this
self
=
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