diff --git a/lib/abstract-class.js b/lib/abstract-class.js index b0cf1655..aa958c5b 100644 --- a/lib/abstract-class.js +++ b/lib/abstract-class.js @@ -336,7 +336,7 @@ AbstractClass.all = function all(params, cb) { collection = data.map(function (d) { var obj = null; // do not create different instances for the same object - var cached = getCached(constr, d.id); + var cached = d && getCached(constr, d.id); if (cached) { obj = cached; // keep dirty attributes untouthed (remove from dataset) @@ -350,6 +350,9 @@ AbstractClass.all = function all(params, cb) { } return obj; }); + if (data && data.countBeforeLimit) { + collection.countBeforeLimit = data.countBeforeLimit; + } cb(err, collection); } });