Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most efficient way to store boolean values in Firebase DB

Basically, I need to know what takes less storage space and traffic - 1/0, "1"/"0" or true/false?

Thanks!

like image 851
zarsky Avatar asked Jul 10 '17 12:07

zarsky


1 Answers

Most efficient way to store a boolean is to set the value as a boolean. That's why Firebase creators offered us this possibility. Storing the value as a boolean offers everything that Java Boolean Class offers. It's not a good practice, to use 0 or 1 in stead of a boolean.

Regarding space, yes it's a difference. Try create to 1000 records with true and false, then create other 1000 record with 0 and 1, export the JSON file and you see the difference.

like image 81
Alex Mamo Avatar answered Nov 15 '22 00:11

Alex Mamo