Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does priority mean in Firebase?

Tags:

firebase

I have read the Firebase docs about priorities but I don't think I understand it yet.

I think I understand that it is related to querying and sorting data. To give my question (and the answers) some weight, in what instances might you use priorities?

From the docs I read that you can set priorities when you set a value at some reference, and then when you query that reference priority determines the ordering based on its type and value. And that makes some sense but I'm not quite understanding it.

like image 306
nodebase Avatar asked Jul 23 '15 03:07

nodebase


1 Answers

Disclosure: I work for Firebase.

Priorities are an optional (numeric or alphanumeric) value of each node, which is used to sort the children under a specific parent or in a query if no other sort condition is specified. The priority of a node is hidden from most views of the data. In cases where a priority is specified for a node, it can be found as a .priority property in the exportVal() of a snapshot.

Since Firebase added the ability to order children on a specified property, priorities have lost most of their value. They are a left-over artifact from the time before Firebase had orderByChild queries. If you are starting on a Firebase project today, you should use orderByChild instead of relying on priorities.

like image 88
Frank van Puffelen Avatar answered Oct 20 '22 16:10

Frank van Puffelen