Skip to content

Commit 0797b42

Browse files
committed
Remove results if limit = 0;
1 parent 3f66c30 commit 0797b42

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/RestQuery.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -325,23 +325,26 @@ RestQuery.prototype.replaceDontSelect = function() {
325325
// Returns a promise for whether it was successful.
326326
// Populates this.response with an object that only has 'results'.
327327
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+
}
333335
}
334336
}
335337

336-
this.config.filesController.expandFilesInObject(this.config, results);
338+
this.config.filesController.expandFilesInObject(this.config, results);
337339

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+
}
345348
}
346349
}
347350
return newObject;
@@ -352,9 +355,12 @@ RestQuery.prototype.runFind = function() {
352355
for (var r of results) {
353356
r.className = this.redirectClassName;
354357
}
355-
}
356-
this.response = {results: results};
357-
});
358+
this.response = {results: results};
359+
});
360+
} else {
361+
this.response = {results: []};
362+
return Promise.resolve();
363+
}
358364
};
359365

360366
// Returns a promise for whether it was successful.

src/Routers/ClassesRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class ClassesRouter extends PromiseRouter {
2323
if (body.skip) {
2424
options.skip = Number(body.skip);
2525
}
26-
if (body.limit) {
26+
if (body.limit || body.limit === 0) {
2727
options.limit = Number(body.limit);
2828
} else {
2929
options.limit = Number(100);

0 commit comments

Comments
 (0)