Skip to content

Commit

Permalink
feat: add json option to query.each
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis committed Sep 2, 2022
1 parent e08f3b6 commit 299fb0d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions integration/test/ParseQueryTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ describe('Parse Query', () => {
assert.strictEqual(result.foo, 'bar');
assert.strictEqual(result.className, 'TestObject');
assert.strictEqual(result.objectId, object.id);

await query.each((obj) => {
assert.strictEqual(obj instanceof Parse.Object, false);
assert.strictEqual(obj.foo, 'bar');
assert.strictEqual(obj.className, 'TestObject');
assert.strictEqual(obj.objectId, object.id);
}, { json: true });
});

it('can do query with count', async () => {
Expand Down
3 changes: 3 additions & 0 deletions src/ParseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@ class ParseQuery {
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
findOptions.context = options.context;
}
if (options.hasOwnProperty('json')) {
findOptions.json = options.json;
}

let finished = false;
let previousResults = [];
Expand Down
7 changes: 7 additions & 0 deletions src/__tests__/ParseQuery-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,13 @@ describe('ParseQuery', () => {
expect(result.size).toBe('small');
expect(result.name).toEqual('Product 3');
expect(result.className).toEqual('Item');

await q.each((obj) => {
expect(obj.objectId).toBe('I1');
expect(obj.size).toBe('small');
expect(obj.name).toEqual('Product 3');
expect(obj.className).toEqual('Item');
}, { json: true });
});

it('will error when getting a nonexistent object', done => {
Expand Down

0 comments on commit 299fb0d

Please sign in to comment.