Skip to content

Commit 05ae010

Browse files
committed
Kill mongoOptions
1 parent d428041 commit 05ae010

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/Controllers/DatabaseController.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,6 @@ DatabaseController.prototype.find = function(className, query, {
631631
sort,
632632
count,
633633
} = {}) {
634-
let mongoOptions = {};
635-
if (skip) {
636-
mongoOptions.skip = skip;
637-
}
638-
if (limit) {
639-
mongoOptions.limit = limit;
640-
}
641634
let isMaster = acl === undefined;
642635
let aclGroup = acl || [];
643636
let op = typeof query.objectId == 'string' && Object.keys(query).length === 1 ? 'get' : 'find';
@@ -653,8 +646,8 @@ DatabaseController.prototype.find = function(className, query, {
653646
throw error;
654647
})
655648
.then(schema => {
649+
const transformedSort = {};
656650
if (sort) {
657-
mongoOptions.sort = {};
658651
for (let fieldName in sort) {
659652
// Parse.com treats queries on _created_at and _updated_at as if they were queries on createdAt and updatedAt,
660653
// so duplicate that behaviour here.
@@ -673,7 +666,7 @@ DatabaseController.prototype.find = function(className, query, {
673666
throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, `Cannot sort by ${fieldName}`);
674667
}
675668
const mongoKey = this.transform.transformKey(className, fieldName, schema);
676-
mongoOptions.sort[mongoKey] = sort[fieldName];
669+
transformedSort[mongoKey] = sort[fieldName];
677670
}
678671
}
679672
return (isMaster ? Promise.resolve() : schemaController.validatePermission(className, aclGroup, op))
@@ -698,7 +691,7 @@ DatabaseController.prototype.find = function(className, query, {
698691
if (count) {
699692
return this.adapter.count(className, query, schema);
700693
} else {
701-
return this.adapter.find(className, query, schema, mongoOptions)
694+
return this.adapter.find(className, query, schema, { skip, limit, sort: transformedSort })
702695
.then(objects => objects.map(object => filterSensitiveData(isMaster, aclGroup, className, object)));
703696
}
704697
});

0 commit comments

Comments
 (0)