I am building a twitter clone and want to create a feed showing only posts made by companies the user followed.
I have four databases:
User
Company
Posts (linked to Company)
Follows (that records if a User follows a Company)
What I am trying to is:
Search for posts
Constraint: post-company (in the Posts DB) is in the Follows database where follow-user = CurrentUser
Am I making this more complicated that I need it to be?
Hi there, @anon57363343… I wouldn’t say you are making it more complicated than it needs to be, but I might go a different way and bring privacy rules into the mix. Assuming a user isn’t going to be following hundreds of companies, I might have a list field called followed companies
on the User
data type. Then, I would set up a privacy rule on the Post
data type that makes posts visible when the Current User's followed companies contains This Post's post-company
. With that setup in place, you wouldn’t need any constraints on your search for posts because the privacy rule would take care of showing the right posts to the right users.
Anyway, just food for thought there, and I hope it helps.
Best…
Mike
Thanks Mike.
Interesting solution but I do need posts to be accessible to everyone. I just need to filter them in the user’s feed (only showing posts from companies they follow)
Ah, okay. Well, for what it’s worth, the data structure I proposed with this constraint on the repeating group’s data source would do the trick (and you would ditch the privacy rule I suggested, of course).