Optimizing 'Favorites' tab

Hi All,

I have a "favorites" tab on a page that I am trying to optimize. Right now, it works, but each row in the list is a separate query to the backend, causing a lot of reads.

1) I have a field in my "users" that is a list that references a "channels" document. Basically, when the user clicks on a toggle Icon, it either adds or removes the channel from this list.

2) In a tab called "Favorites" I display all the channels that a user has favorited by generating dynamic children from this 'isFavorite' list mentioned above in #1.

So I am able to display the list I want, I just can't cache it because it's not a backend query to the Channels collection.

I guess the preferred method would be to do a backend query to the Channel collection to display the list of documents and cache it. Then, filter for only those in the 'isFavorite' list in my users document. But this is where I am struggling, as I can't seem to figure out how to filter based on that. Any ideas? How are favorites typically handled?

2
7 replies