How to approach handling database data with local data?

This has been on my mind for years but haven't completely addressed it. Looking for some expertise with this.

In Firestore, I have a collection of courses. In each document, a single course, I have a name and a list of students.

In the app I have a dropdown menu that shows each of the courses. I choose a course and a Listview shows each of the students. As you might imagine, there will be very few changes to these courses, other than adding or renaming a student here and there.

Right now I'm always querying the database when I choose a course from the dropdown to get the students. I'm stuck between the two ideas of always reading the database, since 6 reads, which is the number of courses, really isn't a big deal. But then I think, what if the user keeps choosing a different course from the dropdown, for no apparent reason. Now I have more reads. Now if a thousand people do this, then that's more reads.

So then I go down the rabbit hole of making a local copy of what is in the database, but now I have a bunch more code to develop and maintain because of this whole syncing of offline to online. Seems like a lot of work for not a lot of payoff.

This is just a simple example, but what approach do you all take? I wish I knew more about caching and how it actually works in FlutterFlow. Seems like it doesn't quite work as expected. It seems to cache one list of students even if a different course was chosen from the dropdown. Maybe this would solve a lot of problems, but I'm not sure how to implement it properly.

What's the default setup that you take? Thanks.

4 replies