Skip to content

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

Closed

Description

@newdev7

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.

Activity

  1. flovilmart commented on Jun 28, 2018

    @flovilmart
    Contributor

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

  2. dplewis commented on Jun 30, 2018

    @dplewis
    Member

    @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.

  3. newdev7 commented on Jul 2, 2018

    @newdev7
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions