Back-end query Tagged User OR "Public" post

Database & APIs

Hi,

I'm creating a database where some documents are "Public" and others are "Private". I want the public documents to appear for everyone but the private documents to appear only for the tagged users. I want all relevant documents to appear together in a list.

It is easy to set up these rules in firestore but I can't find a method to query and get both types of documents without an error occurring. Instead, I think I would need 1 query for public documents and a second query for tagged documents. However, then the items wouldn't show up in the same list. Any suggestions?

For example, I might have the following documents in my collection...

-Public doc 1

-Public doc 2

-Private doc "user A"

-Private doc "user B"

For user A I want a query that will return the first 3 documents.

Thanks!

What have you tried so far?

I can change the backend database to return only the public docs or only the tagged docs, but not both at the same time.

I can update the firestore rules so the query returns all results and then I can filter them with dynamic children, but then private user documents might not be secure.

I can make 2 separate queries then use a custom action to combine all of relevant results. However, I would rather work directly with the query results rather than with data that is saved locally.

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