-
-
Notifications
You must be signed in to change notification settings - Fork 597
Description
Is your feature request related to a problem? Please describe.
Currently ParseQuery.aggregate()
ignores all the conditions of a query created with the Query functions: equalTo()
, matchesQuery()
, matchesKeyInQuery
, or event ParseRelation.query()
...
So it becomes extremely difficult to aggregate complex because aggregate()
relies only on the pipeline argument.
Example:
return Parse.Query
.or(
this.relation('characters').query(),
new Parse.Query('Character')
.equalTo('objectId', this.get('character').id),
new Parse.Query('Character')
.matchesKeyInQuery('objectId', 'character.objectId',
this.relation('clues').query())
)
.aggregate(pipeline); // Using aggregate will ignore the previous conditions
Describe the solution you'd like
ParseQuery.aggregate()
should merge the previous conditions with the ones in the pipeline.
Describe alternatives you've considered
Right now, most of the requirements can be achieved by adding the conditions in a $match
statement at the beginning of the pipeline:
const q = Parse.Query
.or(
this.relation('characters').query(),
new Parse.Query('Character')
.equalTo('objectId', this.get('character').id),
new Parse.Query('Character')
.matchesKeyInQuery('objectId', 'character.objectId',
this.relation('clues').query())
);
const pipeline = [
{ match: q.toJSON().where },
{ ... }
];
return new Parse.Query('Character').aggregate(pipeline);
Additional context
Other constraints like include()
, limit()
, etc will not be passed in where
, but those can be added easily at the end of the pipeline if required.