@@ -631,13 +631,6 @@ DatabaseController.prototype.find = function(className, query, {
631
631
sort,
632
632
count,
633
633
} = { } ) {
634
- let mongoOptions = { } ;
635
- if ( skip ) {
636
- mongoOptions . skip = skip ;
637
- }
638
- if ( limit ) {
639
- mongoOptions . limit = limit ;
640
- }
641
634
let isMaster = acl === undefined ;
642
635
let aclGroup = acl || [ ] ;
643
636
let op = typeof query . objectId == 'string' && Object . keys ( query ) . length === 1 ? 'get' : 'find' ;
@@ -653,8 +646,8 @@ DatabaseController.prototype.find = function(className, query, {
653
646
throw error ;
654
647
} )
655
648
. then ( schema => {
649
+ const transformedSort = { } ;
656
650
if ( sort ) {
657
- mongoOptions . sort = { } ;
658
651
for ( let fieldName in sort ) {
659
652
// Parse.com treats queries on _created_at and _updated_at as if they were queries on createdAt and updatedAt,
660
653
// so duplicate that behaviour here.
@@ -673,7 +666,7 @@ DatabaseController.prototype.find = function(className, query, {
673
666
throw new Parse . Error ( Parse . Error . INVALID_KEY_NAME , `Cannot sort by ${ fieldName } ` ) ;
674
667
}
675
668
const mongoKey = this . transform . transformKey ( className , fieldName , schema ) ;
676
- mongoOptions . sort [ mongoKey ] = sort [ fieldName ] ;
669
+ transformedSort [ mongoKey ] = sort [ fieldName ] ;
677
670
}
678
671
}
679
672
return ( isMaster ? Promise . resolve ( ) : schemaController . validatePermission ( className , aclGroup , op ) )
@@ -698,7 +691,7 @@ DatabaseController.prototype.find = function(className, query, {
698
691
if ( count ) {
699
692
return this . adapter . count ( className , query , schema ) ;
700
693
} else {
701
- return this . adapter . find ( className , query , schema , mongoOptions )
694
+ return this . adapter . find ( className , query , schema , { skip , limit , sort : transformedSort } )
702
695
. then ( objects => objects . map ( object => filterSensitiveData ( isMaster , aclGroup , className , object ) ) ) ;
703
696
}
704
697
} ) ;
0 commit comments