@@ -325,26 +325,29 @@ RestQuery.prototype.replaceDontSelect = function() {
325325// Returns a promise for whether it was successful.
326326// Populates this.response with an object that only has 'results'.
327327RestQuery . prototype . runFind = function ( ) {
328- if ( this . findOptions . limit !== 0 ) {
329- return this . config . database . find (
330- this . className , this . restWhere , this . findOptions ) . then ( ( results ) => {
331- if ( this . className === '_User' ) {
332- for ( var result of results ) {
333- delete result . password ;
334- }
328+ if ( this . findOptions . limit === 0 ) {
329+ this . response = { results : [ ] } ;
330+ return Promise . resolve ( ) ;
331+ }
332+ return this . config . database . find (
333+ this . className , this . restWhere , this . findOptions ) . then ( ( results ) => {
334+ if ( this . className === '_User' ) {
335+ for ( var result of results ) {
336+ delete result . password ;
335337 }
338+ }
336339
337- this . config . filesController . expandFilesInObject ( this . config , results ) ;
340+ this . config . filesController . expandFilesInObject ( this . config , results ) ;
338341
339- if ( this . keys ) {
340- var keySet = this . keys ;
341- results = results . map ( ( object ) => {
342- var newObject = { } ;
343- for ( var key in object ) {
344- if ( keySet . has ( key ) ) {
345- newObject [ key ] = object [ key ] ;
346- }
342+ if ( this . keys ) {
343+ var keySet = this . keys ;
344+ results = results . map ( ( object ) => {
345+ var newObject = { } ;
346+ for ( var key in object ) {
347+ if ( keySet . has ( key ) ) {
348+ newObject [ key ] = object [ key ] ;
347349 }
350+ }
348351 return newObject ;
349352 } ) ;
350353 }
@@ -354,12 +357,8 @@ RestQuery.prototype.runFind = function() {
354357 r . className = this . redirectClassName ;
355358 }
356359 }
357- this . response = { results : results } ;
358- } ) ;
359- } else {
360- this . response = { results : [ ] } ;
361- return Promise . resolve ( ) ;
362- }
360+ this . response = { results : results } ;
361+ } ) ;
363362} ;
364363
365364// Returns a promise for whether it was successful.
0 commit comments