From 341374e7539d7fef88858ba53a04548f31c33107 Mon Sep 17 00:00:00 2001 From: dblythy Date: Sat, 17 Sep 2022 21:54:40 +1000 Subject: [PATCH] feat: allow aggregate with `raw` --- spec/ParseQuery.Aggregate.spec.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spec/ParseQuery.Aggregate.spec.js b/spec/ParseQuery.Aggregate.spec.js index 04fa6068ed..0e9b8f8963 100644 --- a/spec/ParseQuery.Aggregate.spec.js +++ b/spec/ParseQuery.Aggregate.spec.js @@ -581,6 +581,34 @@ describe('Parse.Query Aggregate testing', () => { .catch(done.fail); }); + fit('can aggregate with fakepointer', async () => { + const pointer = new PointerObject(); + const obj = new TestObject({ fakepointer: pointer, name: 'hello' }); + await obj.save(); + const pipeline = [ + {group: { _id: '$_p_fakepointer'}}, + ]; + const query = new Parse.Query(TestObject); + const results = await query.aggregate(pipeline); + console.log(results[0]); + }); + + fit('can aggregate with raw', async () => { + const pointer = new PointerObject(); + const obj = new TestObject({ fakepointer: pointer, name: 'hello' }); + await obj.save(); + const pipeline = [ + { match: { objectId: obj.id } }, + { project: { name: 1 } }, + { + addFields : { fakepointer : {'_id': 1} } + } + ]; + const query = new Parse.Query(TestObject); + const results = await query.aggregate(pipeline); + console.log(results[0]); // { name: 'hello', fakepointer: { _id: 1 }, objectId: '9P7ktS91Xg' } + }); + it('limit query', done => { const options = Object.assign({}, masterKeyOptions, { body: {