create + use adapter count instead of collection count
This commit is contained in:
@@ -123,11 +123,9 @@ describe('InstallationsRouter', () => {
|
|||||||
|
|
||||||
var router = new InstallationsRouter();
|
var router = new InstallationsRouter();
|
||||||
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
rest.create(config, auth.nobody(config), '_Installation', androidDeviceRequest)
|
||||||
.then(() => {
|
.then(() => rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest))
|
||||||
return rest.create(config, auth.nobody(config), '_Installation', iosDeviceRequest);
|
.then(() => router.handleFind(request))
|
||||||
}).then(() => {
|
.then((res) => {
|
||||||
return router.handleFind(request);
|
|
||||||
}).then((res) => {
|
|
||||||
var response = res.response;
|
var response = res.response;
|
||||||
expect(response.results.length).toEqual(2);
|
expect(response.results.length).toEqual(2);
|
||||||
expect(response.count).toEqual(2);
|
expect(response.count).toEqual(2);
|
||||||
|
|||||||
@@ -205,6 +205,12 @@ export class MongoStorageAdapter {
|
|||||||
.then(objects => objects.map(object => transform.mongoObjectToParseObject(className, object, schema)));
|
.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() {
|
get transform() {
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -699,7 +699,7 @@ DatabaseController.prototype.find = function(className, query, {
|
|||||||
if (count) {
|
if (count) {
|
||||||
let mongoWhere = this.transform.transformWhere(className, query, schema);
|
let mongoWhere = this.transform.transformWhere(className, query, schema);
|
||||||
delete mongoOptions.limit;
|
delete mongoOptions.limit;
|
||||||
return collection.count(mongoWhere, mongoOptions);
|
return this.adapter.count(className, mongoWhere, mongoOptions);
|
||||||
} else {
|
} else {
|
||||||
return this.adapter.find(className, query, mongoOptions, schema)
|
return this.adapter.find(className, query, mongoOptions, schema)
|
||||||
.then(objects => objects.map(object => filterSensitiveData(isMaster, aclGroup, className, object)));
|
.then(objects => objects.map(object => filterSensitiveData(isMaster, aclGroup, className, object)));
|
||||||
|
|||||||
Reference in New Issue
Block a user