Home > database >  Host function on firestore for an android app?
Host function on firestore for an android app?

Time:10-20

I'm trying to developp an android app which will use a firestore's database. The user can click on a button to collect data from all user's. I noticed it took a while to do (the app check the database, then for each user which are documents read their values, do a calcul based on the time since they have created their account, then add all of that into a number).

I was wondering if there would be a more optimised way to do this ? Like is this possible to have, like a function or I don't know how to call it, on the firestore server that would do this calcul like each minute or hour, then the app only query the result store in a int on the database ?

I'm a newbie in this field so I might not be using the right terms for things.

Thanks

CodePudding user response:

Performing calculations by reading a bunch of data on each client is typically an anti-pattern when using NoSQL database like Firestore. They're best if you have a fairly direct mapping from the data in the database to what you show in the screens of your app.

Firestore has no built-in server-side calculations on its own. You'll typically want to perform those in something like Cloud Functions, which can either run in response to writing to Firestore (and other Firebase and Google Cloud products), or run periodically on a schedule.

  • Related