mardi 12 mai 2020

Scalable way to track habits in Firestore?

I am working on a habit tracking application using Firestore as my database.

I was wondering about how to display completed habits and habit streaks in the front end of my mobile application. I understand that Firebase charges based on reads and I want to make my data structured in a way that maximizes efficiency.

This is how the database is currently structured:

habits
    - habit id
        - information (user id, name, etc.)

events
    - event_id
        - information (habit id, date)

On the first page, I would be displaying the current streak and if the habit is completed for that day.

Note: This page has to check if the habit is completed, toggle this completion, and check the current streaks for ALL habits

On the second app page, I query ALL the events from that habit and populate a Calendar View and also show the current and best streak for that specific habit.

Is there any efficient way for my habit tracking app to efficiently store and read this streak data?

These streaks are updated with the app's current day on loading.

Should I use Cloud Functions, Incrementing, Pagination, or perform the logic locally?

What is the BEST solution to this problem? Should I completely restart and switch to another service?

Aucun commentaire:

Enregistrer un commentaire