Skip to content

Commit 14938bb

Browse files
committed
create + use adapter count instead of collection count
1 parent 1ae1d42 commit 14938bb

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

spec/InstallationsRouter.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ describe('InstallationsRouter', () => {
123123

124124
var router = new InstallationsRouter();
125125
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
126-
.then(() => {
127-
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
128-
}).then(() => {
129-
return router.handleFind(request);
130-
}).then((res) => {
126+
.then(() => rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest))
127+
.then(() => router.handleFind(request))
128+
.then((res) => {
131129
var response = res.response;
132130
expect(response.results.length).toEqual(2);
133131
expect(response.count).toEqual(2);

src/Adapters/Storage/Mongo/MongoStorageAdapter.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ export class MongoStorageAdapter {
205205
.then(objects => objects.map(object => transform.mongoObjectToParseObject(className, object, schema)));
206206
}
207207

208+
// Executs a count.
209+
count(className, query, mongoOptions) {
210+
return this.adaptiveCollection(className)
211+
.then(collection => collection.count(query, mongoOptions));
212+
}
213+
208214
get transform() {
209215
return transform;
210216
}

src/Controllers/DatabaseController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ DatabaseController.prototype.find = function(className, query, {
699699
if (count) {
700700
let mongoWhere = this.transform.transformWhere(className, query, schema);
701701
delete mongoOptions.limit;
702-
return collection.count(mongoWhere, mongoOptions);
702+
return this.adapter.count(className, mongoWhere, mongoOptions);
703703
} else {
704704
return this.adapter.find(className, query, mongoOptions, schema)
705705
.then(objects => objects.map(object => filterSensitiveData(isMaster, aclGroup, className, object)));

0 commit comments

Comments
 (0)