Firebase 中的优先级是什么意思? [英] What does priority mean in Firebase?

查看:28
本文介绍了Firebase 中的优先级是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了有关优先级的 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.

推荐答案

披露:我为 Firebase 工作.

优先级是每个节点的可选(数字或字母数字)值,用于在未指定其他排序条件的情况下对特定父项下或查询中的子项进行排序.节点的优先级对大多数数据视图是隐藏的.如果为节点指定了优先级,则可以在快照的 exportVal() 中的 .priority 属性中找到它.

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.

自从 Firebase 添加了对指定属性上的子项进行排序的功能后,优先级失去了大部分价值.它们是 Firebase 有 orderByChild 查询之前的遗留产物.如果您今天开始一个 Firebase 项目,您应该使用 orderByChild 而不是依赖优先级.

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.

这篇关于Firebase 中的优先级是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆