Is there a fast way to perform database-style queries with Firebase?
For example:
Given a firebase reference users with fields user_id, name, and age, what would be the best way to do a query similar to this:
SELECT name FROM users WHERE `user_id`=147;
and
SELECT COUNT(*) FROM users WHERE age=21;
In general, no. Firebase is essentially a “realtime database”, constantly streaming updates to you as data changes, so it’s more difficult to do general-purpose querying. For now, there are a couple of (admittedly limited) querying primitives that are provided. See the Queries/Limits page in the docs.
You can often work around these limitations through a variety of approaches:
We intend to improve on this over time, as we realize it’s a weak spot compared to the flexible querying provided by traditional relational database systems.