Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
Include with asJson bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Waldmann committed Jul 10, 2014
1 parent 6cb6b7c commit ec8cac4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions lib/persistence/include.js
Expand Up @@ -256,6 +256,7 @@ exports.definition = {
var records = base.records[n][sub_records[i][relation.foreign_key]];
for(var r in records){
if(base.as && base.take){
//TODO: check relation type as well (see below..)
records[r][base.as] = records[r][base.as] || [];
var sr = sub_records[i][base.take[0]];

Expand All @@ -264,8 +265,12 @@ exports.definition = {
}
records[r][base.as].push(sr);
}else{
records[r][relation.name] = records[r][relation.name] || [];
records[r][relation.name].push(sub_records[i]);
if(base.relation.type === 'has_many'){
records[r][relation.name] = records[r][relation.name] || [];
records[r][relation.name].push(sub_records[i]);
}else{
records[r][relation.name] = records[r][relation.name] || sub_records[i];
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/stores/sql/save.js
Expand Up @@ -248,7 +248,7 @@ exports.model = {
* @param {integer} affected_records - The number of affected records
* @this Collection
*
* @return {Model}
* @return {Promise}
*/
update: function(attributes, options, resolve, reject){
return this.updateAll(attributes, options, resolve, reject);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "openrecord",
"version": "1.1.0",
"version": "1.1.1",
"description": "Active record like ORM for nodejs",
"keywords": ["orm", "record", "sql", "sqlite3", "postgres", "pg", "mysql", "database", "activerecord", "promise", "rest", "restify", "nested set"],
"author": "Philipp Waldmann <philipp.waldmann@s-team.at>",
Expand Down

0 comments on commit ec8cac4

Please sign in to comment.