Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement: firebase database for user-preferences in our apps #246

Open
amansinghbais opened this issue Jan 8, 2024 · 1 comment
Open

Comments

@amansinghbais
Copy link
Contributor

Currently, we are storing user-preferences in a app to the backend. For better experience, we want to read and write our user-preferences to the database of the firebase.

Task:

  1. Find a database suitable for our usecase out of all the firebase databases.
  2. Implement code to do CRUD operation on that database.
@amansinghbais amansinghbais self-assigned this Jan 8, 2024
@amansinghbais
Copy link
Contributor Author

amansinghbais commented Jan 10, 2024

What is Firebase ?

Firebase is a Backend-as-a-Service (BaaS) app development platform that provides hosted backend services such as a realtime database, cloud storage, authentication, crash reporting, machine learning, remote configuration, and hosting for your static files.

Types of firebase databases: ----

1. Firestore

  • Cloud Firestore is the recommended enterprise-grade JSON-compatible document database, trusted by more than 250,000 developers. It's suitable for applications with rich data models requiring queryability, scalability, and high availability. It also offers low latency client synchronization and offline data access.

2. Realtime

  • Realtime Database is the classic Firebase JSON database. It's suitable for applications with simple data models requiring simple lookups and low-latency synchronization with limited scalability.

Database free tier limits

Realtime Database

  • Simultaneous connections : 100
  • GB stored : 1 GB
  • GB downloaded : 10 GB/month
  • Single database per project

Firebase Database

  • Stored Data : 1GiB total
  • Network egress : 10 GiB/month
  • Document writes : 20K writes/day
  • Document reads : 50K reads/day
  • Document deletes : 20K deletes/day

Firebase vs Realtime Database

Firebase

  • Stores database as a collection of documents. Suitable for complex / hierarchical data using subcollections within documents.
  • Suitable for complex queries. You can chain filters and combine filtering and sorting on a property in a single query.
  • Queries are indexed by default: Query performance is proportional to the size of your result set, not your dataset.
  • Scales completely automatically. Scaling limits are around 1 million concurrent connections and 10,000 writes/second.

Realtime

  • Stores data as one large JSON tree. Suitable for simple data as complex / hierarchical data is harder to organize at scale.
  • Suitable for simple queries. Queries can sort or filter on a property, but not both. Queries are deep by default: they always return the entire subtree.
  • Queries can access data at any granularity, down to individual leaf-node values in the JSON tree.
  • Queries don't require an index; however the performance of certain queries degrades as your dataset grows.
  • Scale to around 200,000 concurrent connections and 1,000 writes/second in a single database. Scaling beyond that requires sharding your data across multiple databases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🛑 On hold
Development

No branches or pull requests

1 participant