Filtering posts based on matching relationships (fruit matching posts)

I’m trying to filter a list based on relationships and am quite stumped. Any advice would be much appreciated!

Since my app is quite complicated (lots of collections) intertwined, I’ve tried to make this as simple as possible through an example.

Database premise

  • Let’s say I have the collections: users, posts, and fruits.
  • Users are related to fruit, such that they can pick which ones they like, e.g. apples and oranges, but not bananas or pears.
  • Users are related to posts, as people can write posts and are designated the author.
  • Users are related to other users, as people can essentially friend each other.
  • Posts are related to fruit, as the post author can choose what fruit a post is about (e.g. bananas and oranges).

What I am trying to do
I have a timeline in which users can see posts authored by their friends. This part is the easy part.

Here’s the challenging part. I want users to only see posts about fruit they like. For example, if I like apples and bananas, I want to only see posts about apples and bananas but I do not want to see posts about apples or apples and pears, etc.

I’m essentially wondering if I can filter lists based on having a matching relationship, i.e. the fruit I like are the same as fruit the post is about. Is this possible? Are there any work arounds really grateful if anyone has any tips!

Hi @sammccolgan ,

I modify earlier cloneable app and made a little improvement.

Screen Recording 2022-02-09 at 9.41.44 AM

You can check if it suits to your need.

1 Like

Hi @Yongki,

Thanks so much for getting back. I see you’ve essentially added the function to like fruit, and show who likes what fruit in a list. That’s great, but I’m looking to do something that goes a step further. I want users to only see posts from people about certain food they like.

For example:
Sue makes a post about apples and bananas.
Bill cannot see the post because he only likes apples.
Sara cannot see the post because she likes oranges and bananas.
Paul sees the post because he likes apples and bananas.

Hi @sammccolgan ,

I have updated the app, you can clone again.

To save time, the password is the first letter of the email.

I introduce OR function too, which is basically greater than 0.

There are 2 types of filter matching, 1-to-M which can be used for quick search and M-to-M which can be preferences.

I hope this can shine some light of what Adalo is capable despite its shortcomings.

This platform is really powerful which even enable us to push boundaries of common app in the context of database relationship, because it is designed with database capability from the start.