Group aggregation supports multiple columns for postgres (#6483)

* Group aggregation supports multiple columns for postgres

* Group aggregation supports multiple columns for postgres

* Group aggregation supports multiple columns for postgres

* Group aggregation supports multiple columns for postgres
This commit is contained in:
Siddharth Ramesh
2020-03-09 21:48:39 +05:30
committed by GitHub
parent f69545939b
commit ef17dc4382
2 changed files with 61 additions and 21 deletions

View File

@@ -225,6 +225,32 @@ describe('Parse.Query Aggregate testing', () => {
});
});
it('group by multiple columns ', done => {
const obj1 = new TestObject();
const obj2 = new TestObject();
const obj3 = new TestObject();
const pipeline = [
{
group: {
objectId: {
score: '$score',
views: '$views',
},
count: { $sum: 1 },
},
},
];
Parse.Object.saveAll([obj1, obj2, obj3])
.then(() => {
const query = new Parse.Query(TestObject);
return query.aggregate(pipeline);
})
.then(results => {
expect(results.length).toEqual(5);
done();
});
});
it('group by date object', done => {
const obj1 = new TestObject();
const obj2 = new TestObject();
@@ -963,25 +989,29 @@ describe('Parse.Query Aggregate testing', () => {
await Parse.Object.saveAll([obj1, obj2, obj3, obj4, obj5, obj6]);
expect(
(await new Parse.Query('MyCollection').aggregate([
{
match: {
language: { $in: [null, 'en'] },
(
await new Parse.Query('MyCollection').aggregate([
{
match: {
language: { $in: [null, 'en'] },
},
},
},
]))
])
)
.map(value => value.otherField)
.sort()
).toEqual([1, 2, 3, 4]);
expect(
(await new Parse.Query('MyCollection').aggregate([
{
match: {
$or: [{ language: 'en' }, { language: null }],
(
await new Parse.Query('MyCollection').aggregate([
{
match: {
$or: [{ language: 'en' }, { language: null }],
},
},
},
]))
])
)
.map(value => value.otherField)
.sort()
).toEqual([1, 2, 3, 4]);