diff --git a/spec/InstallationsRouter.spec.js b/spec/InstallationsRouter.spec.js index 82416aa4..2d7224a0 100644 --- a/spec/InstallationsRouter.spec.js +++ b/spec/InstallationsRouter.spec.js @@ -123,11 +123,9 @@ describe('InstallationsRouter', () => { var router = new InstallationsRouter(); rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest) - .then(() => { - return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest); - }).then(() => { - return router.handleFind(request); - }).then((res) => { + .then(() => rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest)) + .then(() => router.handleFind(request)) + .then((res) => { var response = res.response; expect(response.results.length).toEqual(2); expect(response.count).toEqual(2); diff --git a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js index 5768262a..2bec9895 100644 --- a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js +++ b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js @@ -205,6 +205,12 @@ export class MongoStorageAdapter { .then(objects => objects.map(object => transform.mongoObjectToParseObject(className, object, schema))); } + // Executs a count. + count(className, query, mongoOptions) { + return this.adaptiveCollection(className) + .then(collection => collection.count(query, mongoOptions)); + } + get transform() { return transform; } diff --git a/src/Controllers/DatabaseController.js b/src/Controllers/DatabaseController.js index db2276ff..c3f92b1f 100644 --- a/src/Controllers/DatabaseController.js +++ b/src/Controllers/DatabaseController.js @@ -699,7 +699,7 @@ DatabaseController.prototype.find = function(className, query, { if (count) { let mongoWhere = this.transform.transformWhere(className, query, schema); delete mongoOptions.limit; - return collection.count(mongoWhere, mongoOptions); + return this.adapter.count(className, mongoWhere, mongoOptions); } else { return this.adapter.find(className, query, mongoOptions, schema) .then(objects => objects.map(object => filterSensitiveData(isMaster, aclGroup, className, object)));