Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$notInQuery, $dontSelect doesn't work with match in aggregate query #4842

Closed
newdev7 opened this issue Jun 15, 2018 · 3 comments
Closed

$notInQuery, $dontSelect doesn't work with match in aggregate query #4842

newdev7 opened this issue Jun 15, 2018 · 3 comments

Comments

@newdev7
Copy link

newdev7 commented Jun 15, 2018

I have one class in which I'm storing user details. In other class I'm storing the messages which is sent and received by the user and every row in the message class has a pointer which points to the receiverId user.

I'm using aggregate to get the unique receiver ids in the message class. For that I'm using some condition that has to satisfy in that corresponding user row.

For e.g.,

Message table has columns userId, receiverId, userData(pointer points to the user data of receiverId), etc.,

User table has columns userId, List1, List2, etc.,
Using aggregate, I'm trying to get the unique values of receiverId in which the given userId must not be in the List1 of receiverId's row.

curl -X GET -H "X-Parse-Application-Id:appID" -H "X-Parse-Master-Key: masterKey" -H "X-Parse-REST-API-Key: apiKey" -G --data-urlencode 'match={"userId":"abcde_12345","userData":{"$notInQuery":{"where":{"List1":"abcde_12345"}},"className":"userClass"}}' -G --data-urlencode 'group={"object":{"userId":"$userId","receiverId":"$receiverId"}}' https://YOUR.PARSE-SERVER.HERE/parse/aggregate/messageClass

For this query, it returns empty row only even if the userId is not in the receiverId's List1.

If I remove, the userData(which contains $notInQuery (or) $dontSelect) from the above query, it returns the values

curl -X GET -H "X-Parse-Application-Id:appID" -H "X-Parse-Master-Key: masterKey" -H "X-Parse-REST-API-Key: apiKey" -G --data-urlencode 'match={"userId":"abcde_12345"}' -G --data-urlencode 'group={"object":{"userId":"$userId","receiverId":"$receiverId"}}' https://YOUR.PARSE-SERVER.HERE/parse/aggregate/messageClass

results:[{object:{userId:abcde_12345, receiverId: abcde_54321},object:{userId:abcde_12345, receiverId: edcba_54321},object:{userId:abcde_12345, receiverId: cdeba_34521}}]

Is $notInQuery, $dontSelect not to be used with match in aggregate query by design or is this a bug?

Thanks.

@flovilmart
Copy link
Contributor

@dplewis I'm not sure we should supprot those nested operators at the moment right? Any way we can support them moving forward?

@dplewis
Copy link
Member

dplewis commented Jun 30, 2018

@newdev7 I can tell from this line here

"$notInQuery":{"where":{"List1":"abcde_12345"}}

where and $notInQuery doesn't exist in the aggregate pipeline.

You should use the standard rest api query constraints for this.

http://docs.parseplatform.org/rest/guide/#query-constraints

I believe there is a way to do this with aggregates.

@dplewis dplewis closed this as completed Jun 30, 2018
@newdev7
Copy link
Author

newdev7 commented Jul 2, 2018

Hi @dplewis

I tried the aggregate pipeline operators like $cmp, $cond in rest api query. But it returned "Internal server error". I'm using MongoDB version 3.4

Could you please suggest me something to get that working with aggregates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants