DocumentReference as query filter: Full reference instead of only Document ID?

Actions & Logic

I'm working on some social features for my app, and I am struggling wiht a collection query where I need to retrieve one document based on a user reference.

Users should be able to connect, and I want to be able to store a number of different situations (sending requests, withdrawing them, blocking someone etc). To do so, I've decided that under "users", I will have a subcollection "connections" where a connection document stores the status of the relationship to another user (from this user's perspective).

For example: If Alice sends a connection request to Bob; and Bob declines it:

  • Alice would have a connections document where the otherUserRef is "/users/Bob" and the status is "sent"

  • Bob would have a connections document where the otherUserRef is "/users/Alice" and the status is "declined"

Now on a user profile page, I need to show the appropriate actions. For example, if no connection has been made, there should be a button saying "Send connection request". If the user viewing the profile has sent a request, it should say "Request sent". Or if the user Bob is viewing the profile of Alice who has made a request to Bob, it should say "Accept Alice's request". So far, so obvious.

I put all of these variants in one container for conditional visibility based on the "status" of the "connection". To get it, I want to query the respective connection in this container. I do not know its reference, so I'm going via "Query Collection" with query type "Single Document".

However, when I set the filter, it never returns any results. In the screenshot, "otherUserRef" is the value in the document, and "refOtherUser" is the page parameter with the DocumentReference to the user about whom I want to know the connection.

I know the filter is the issue because when I remove it, the query will simply return the first connections document, but this is most likely with a different user.

My suspicion is that while the connections document contains a full DocumentReference like "/users/Alice", the page parameter passed into the filter might be only the Document ID "Alice" instead of the full reference.

How do I check if that's the case and if so, how do I fix it?

What have you tried so far?

I've tried around with the query

Did you check FlutterFlow's Documentation for this topic?
Yes
1