We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f076078 commit a727e1cCopy full SHA for a727e1c
3 files changed
spec/RestQuery.spec.js
@@ -191,4 +191,33 @@ describe('rest query', () => {
191
});
192
193
194
+ it('query with limit = 0', (done) => {
195
+ rest.create(config, nobody, 'TestObject', {foo: 'baz'}
196
+ ).then(() => {
197
+ return rest.create(config, nobody,
198
+ 'TestObject', {foo: 'qux'});
199
+ }).then(() => {
200
+ return rest.find(config, nobody,
201
+ 'TestObject', {}, {limit: 0});
202
+ }).then((response) => {
203
+ expect(response.results.length).toEqual(0);
204
+ done();
205
+ });
206
207
+
208
+ it('query with limit = 0 and count = 1', (done) => {
209
210
211
212
213
214
215
+ 'TestObject', {}, {limit: 0, count: 1});
216
217
218
+ expect(response.count).toEqual(2);
219
220
221
222
223
src/RestQuery.js
@@ -325,6 +325,10 @@ RestQuery.prototype.replaceDontSelect = function() {
325
// Returns a promise for whether it was successful.
326
// Populates this.response with an object that only has 'results'.
327
RestQuery.prototype.runFind = function() {
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') {
src/Routers/ClassesRouter.js
@@ -23,7 +23,7 @@ export class ClassesRouter extends PromiseRouter {
23
if (body.skip) {
24
options.skip = Number(body.skip);
25
}
26
- if (body.limit) {
+ if (body.limit || body.limit === 0) {
27
options.limit = Number(body.limit);
28
} else {
29
options.limit = Number(100);
0 commit comments