Join filtered results from two queries to display in a single table

Hello everyone,
I'm currently trying to develop an app for family and friends that can be used to complete challenges.
I am using the following Firebase layout:

users: {collection}

Document: {userid}

Fields:

  • username: {string}

  • email: {string}

  • …etc

tasks: {collection}

Document: {taskID}

Fields:

  • title: {string}

  • description: {string}

  • difficulty: {int}

activities: {collection}

Document: {activityID}

Fields:

  • challenge: {reference: /challenges/taskID}

  • user: {reference: /users/userID}

  • isDone: {bool}

  • isPlanned: {bool}

  • isIgnored: {bool}

 

I would now like to create an overview page with a list view that can be filtered with parameters from the "tasks" and "activities" collections.

E.G.: Show my tasks that I have ignored and have a difficulty level of 5.

In SQL this would be a simple join query and I have massive problems implementing this requirement:

All "activities" assigned to the user are displayed in a list view (easy):

The user can set various filters via a bottom sheet:

 

The filtered results should now be displayed in a new conditional list view.

To do this, I create a backend query in the list view with the filter from the "activities" collection (user=reference && isIgnored=true)

 

Now, where do I define the query for the 2nd collection “tasks”, to combine and display the results? 

I have some SQL background and this seems to me to be a very trivial query, but I just can't wrap my head around this. I tried to nest the 2nd query in the child-elements, create a complex action-flow on page load, nothing worked out so far.

Should I restructure my database schema? Do I need to code? Custom Functions? What would be the best approach to do this?

And I plan to add a "tagging" function so that tasks can be filtered by tags, which would be a third collection. But since I couldn't even create a simple filter, I didn't even dare to think about it.

Appreciate any inputs, thanks!

1
6 replies