@@ -325,23 +325,26 @@ RestQuery.prototype.replaceDontSelect = function() {
325
325
// Returns a promise for whether it was successful.
326
326
// Populates this.response with an object that only has 'results'.
327
327
RestQuery . prototype . runFind = function ( ) {
328
- return this . config . database . find (
329
- this . className , this . restWhere , this . findOptions ) . then ( ( results ) => {
330
- if ( this . className === '_User' ) {
331
- for ( var result of results ) {
332
- delete result . password ;
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
+ }
333
335
}
334
336
}
335
337
336
- this . config . filesController . expandFilesInObject ( this . config , results ) ;
338
+ this . config . filesController . expandFilesInObject ( this . config , results ) ;
337
339
338
- if ( this . keys ) {
339
- var keySet = this . keys ;
340
- results = results . map ( ( object ) => {
341
- var newObject = { } ;
342
- for ( var key in object ) {
343
- if ( keySet . has ( key ) ) {
344
- newObject [ key ] = object [ key ] ;
340
+ if ( this . keys ) {
341
+ var keySet = this . keys ;
342
+ results = results . map ( ( object ) => {
343
+ var newObject = { } ;
344
+ for ( var key in object ) {
345
+ if ( keySet . has ( key ) ) {
346
+ newObject [ key ] = object [ key ] ;
347
+ }
345
348
}
346
349
}
347
350
return newObject ;
@@ -352,9 +355,12 @@ RestQuery.prototype.runFind = function() {
352
355
for ( var r of results ) {
353
356
r . className = this . redirectClassName ;
354
357
}
355
- }
356
- this . response = { results : results } ;
357
- } ) ;
358
+ this . response = { results : results } ;
359
+ } ) ;
360
+ } else {
361
+ this . response = { results : [ ] } ;
362
+ return Promise . resolve ( ) ;
363
+ }
358
364
} ;
359
365
360
366
// Returns a promise for whether it was successful.
0 commit comments