@@ -111,11 +111,11 @@ function RestQuery(config, auth, className, restWhere = {}, restOptions = {}, cl
111
111
// Returns a promise for the response - an object with optional keys
112
112
// 'results' and 'count'.
113
113
// TODO: consolidate the replaceX functions
114
- RestQuery . prototype . execute = function ( ) {
114
+ RestQuery . prototype . execute = function ( executeOptions ) {
115
115
return Promise . resolve ( ) . then ( ( ) => {
116
116
return this . buildRestWhere ( ) ;
117
117
} ) . then ( ( ) => {
118
- return this . runFind ( ) ;
118
+ return this . runFind ( executeOptions ) ;
119
119
} ) . then ( ( ) => {
120
120
return this . runCount ( ) ;
121
121
} ) . then ( ( ) => {
@@ -385,13 +385,13 @@ RestQuery.prototype.replaceDontSelect = function() {
385
385
386
386
// Returns a promise for whether it was successful.
387
387
// Populates this.response with an object that only has 'results'.
388
- RestQuery . prototype . runFind = function ( ) {
388
+ RestQuery . prototype . runFind = function ( options = { } ) {
389
389
if ( this . findOptions . limit === 0 ) {
390
390
this . response = { results : [ ] } ;
391
391
return Promise . resolve ( ) ;
392
392
}
393
393
return this . config . database . find (
394
- this . className , this . restWhere , this . findOptions ) . then ( ( results ) => {
394
+ this . className , this . restWhere , this . findOptions , options . op ) . then ( ( results ) => {
395
395
if ( this . className === '_User' ) {
396
396
for ( var result of results ) {
397
397
delete result . password ;
@@ -479,23 +479,22 @@ function includePath(config, auth, response, path) {
479
479
return response ;
480
480
}
481
481
let pointersHash = { } ;
482
- var objectIds = { } ;
483
482
for ( var pointer of pointers ) {
484
483
if ( ! pointer ) {
485
484
continue ;
486
485
}
487
486
let className = pointer . className ;
488
487
// only include the good pointers
489
488
if ( className ) {
490
- pointersHash [ className ] = pointersHash [ className ] || [ ] ;
491
- pointersHash [ className ] . push ( pointer . objectId ) ;
489
+ pointersHash [ className ] = pointersHash [ className ] || new Set ( ) ;
490
+ pointersHash [ className ] . add ( pointer . objectId ) ;
492
491
}
493
492
}
494
493
495
494
let queryPromises = Object . keys ( pointersHash ) . map ( ( className ) => {
496
- var where = { 'objectId' : { '$in' : pointersHash [ className ] } } ;
495
+ let where = { 'objectId' : { '$in' : Array . from ( pointersHash [ className ] ) } } ;
497
496
var query = new RestQuery ( config , auth , className , where ) ;
498
- return query . execute ( ) . then ( ( results ) => {
497
+ return query . execute ( { op : 'get' } ) . then ( ( results ) => {
499
498
results . className = className ;
500
499
return Promise . resolve ( results ) ;
501
500
} )
0 commit comments