Comparing version 0.3.34 to 0.3.35
@@ -19,2 +19,3 @@ !function(){ | ||
this.group = options.group || []; | ||
this.order = options.order || []; | ||
} | ||
@@ -21,0 +22,0 @@ |
@@ -192,3 +192,7 @@ !function(){ | ||
if (debug) log.info('preparing childResource for ordering «'+childResource.name.yellow+'», selected: '+((!!childResource.selected)+'').yellow+', hasRootFilter: '+((!!childResource.hasRootFilter)+'').yellow+', filtered: '+((!!childResource.filtered)+'').yellow+''); | ||
if (childResource.isRootOrdered) childResource.rootOrder(); | ||
if (childResource.isRootOrdered) { | ||
// go up the tree and left join all required tables | ||
this._orderByChildren(resource); | ||
childResource.rootOrder(); | ||
} | ||
@@ -201,3 +205,10 @@ this._preparechildResourceForOrdering(childResource); | ||
, _orderByChildren: function(resource) { | ||
if (resource.parentResource) { | ||
resource.joinRoot(true); | ||
this._orderByChildren(resource.parentResource); | ||
} | ||
} | ||
, _filterByChildren: function(resource, joins, filter, resourceName) { | ||
@@ -204,0 +215,0 @@ if (!resource.selected) { |
@@ -165,2 +165,14 @@ !function(){ | ||
, joinRoot: function(leftJoin) { | ||
this.joins.reverse().forEach(function(joinStatement, index){ | ||
if (!joinStatement.used) { | ||
joinStatement.used = true; | ||
this.rootResource.query.join.push(joinStatement.reverseFormat(this.id, (index > 0 ? this.id: this.parentResource.id), leftJoin)); | ||
} | ||
}.bind(this)); | ||
} | ||
, selectReferencedColumn: function(columnName) { | ||
@@ -167,0 +179,0 @@ this.query.select.push(columnName); |
{ | ||
"name" : "ee-orm" | ||
, "description" : "An easy to use ORM for node.js. Supports eager loading, complex queries, joins, transactions, complex database clusters & connection pooling." | ||
, "version" : "0.3.34" | ||
, "version" : "0.3.35" | ||
, "homepage" : "https://github.com/eventEmitter/ee-orm" | ||
@@ -6,0 +6,0 @@ , "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)" |
@@ -28,8 +28,3 @@ | ||
var query = db.event(['*']); | ||
query.getVenue(['*']); | ||
query.getVenue(['*'], {id: ORM.or([1,2,3,4])}); | ||
query.getVenue(['*'], {name: ORM.like('Da%')}); | ||
query.find(cb); | ||
db.event(['*']).getVenue(['*']).orderRoot('id').find(cb); | ||
return; | ||
@@ -36,0 +31,0 @@ |
@@ -517,2 +517,6 @@ | ||
}); | ||
it('should order the rootquery using a child resource', function(done) { | ||
db.event(['*']).getVenue(['*']).orderRoot('id').find(expect('[{"id":3,"venue":{"id":1,"name":"Dachstock Reitschule"},"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":true},{"id":4,"venue":{"id":1,"name":"Dachstock Reitschule"},"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":"2014-05-13T16:53:20.000Z","canceled":null},{"id":1,"venue":{"id":2,"name":"Dachstock Reitschule"},"title":"Changed title","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null},{"id":2,"venue":{"id":2,"name":"Dachstock Reitschule"},"title":"Mapping Test","startdate":"1970-01-01T00:00:00.000Z","enddate":null,"canceled":null}]', done)); | ||
}); | ||
}); | ||
@@ -519,0 +523,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187779
3504