Skip to content

Commit 299fb0d

Browse files
committed
feat: add json option to query.each
1 parent e08f3b6 commit 299fb0d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

integration/test/ParseQueryTest.js

+7
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ describe('Parse Query', () => {
7070
assert.strictEqual(result.foo, 'bar');
7171
assert.strictEqual(result.className, 'TestObject');
7272
assert.strictEqual(result.objectId, object.id);
73+
74+
await query.each((obj) => {
75+
assert.strictEqual(obj instanceof Parse.Object, false);
76+
assert.strictEqual(obj.foo, 'bar');
77+
assert.strictEqual(obj.className, 'TestObject');
78+
assert.strictEqual(obj.objectId, object.id);
79+
}, { json: true });
7380
});
7481

7582
it('can do query with count', async () => {

src/ParseQuery.js

+3
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,9 @@ class ParseQuery {
990990
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
991991
findOptions.context = options.context;
992992
}
993+
if (options.hasOwnProperty('json')) {
994+
findOptions.json = options.json;
995+
}
993996

994997
let finished = false;
995998
let previousResults = [];

src/__tests__/ParseQuery-test.js

+7
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,13 @@ describe('ParseQuery', () => {
13761376
expect(result.size).toBe('small');
13771377
expect(result.name).toEqual('Product 3');
13781378
expect(result.className).toEqual('Item');
1379+
1380+
await q.each((obj) => {
1381+
expect(obj.objectId).toBe('I1');
1382+
expect(obj.size).toBe('small');
1383+
expect(obj.name).toEqual('Product 3');
1384+
expect(obj.className).toEqual('Item');
1385+
}, { json: true });
13791386
});
13801387

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

0 commit comments

Comments
 (0)