Home > OS >  How to minimize Firestore data? Mutiple fields with boolean type or one Map field type?
How to minimize Firestore data? Mutiple fields with boolean type or one Map field type?

Time:12-13

I'm making a social media app using flutter and firebase. I'm making push notifications to alert users on certain actions like somebody is following or send a comment or press like button. Also, there will be a push notification settings page.

I want to let users to choose to turn on and off push notifications on certain actions. For example, a user only wants to get push notification when someone is following on him. Then, the user can just turn off all the other push notifications except following push notification.

What I did was make every fields of every push notifications on certain actions. enter image description here

For example, I made 4 data fields in user's firebase document for each certain push notifications.

I have a different idea which is making one field of Map type data that contains multiple push notifications like this.

enter image description here

Which way would be the better idea to minimize the size of Firestore data and reduce the cost?

Thank you so much for reading this and if you have other ideas, please let me know :)

CodePudding user response:

Better have different fields - anyway you will receive one dataset, and you don't need to make another "dataset" in this (in same situation you will receive more long response because of additional string markup for inner json)

Also, if you have different fields you can more efficient query it if you need, with less data exchange between client and server

  • Related