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

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

问题描述

我已经阅读了关于优先级的Firebase文档,但是我不认为我理解它。

我想我明白这与查询和排序数据有关。为了给我的问题(和答案)一些权重,在什么情况下你可以使用优先级?

从我看到的文档,你可以设置优先级,当你设置一个值在某些引用中,然后当您查询引用优先级时,将根据其类型和值确定排序。这是有道理的,但我不是很了解它。

解决方案

泄露:我为Firebase工作。 b

优先级是每个节点的可选(数字或字母数字)值,如果没有指定其他排序条件,则该值用于在特定父级或查询下对子级进行排序。一个节点的优先级对大多数数据视图是隐藏的。在为节点指定优先级的情况下,可以在 exportVal() .priority 属性>

由于Firebase添加了在指定属性上定购子项的功能,所以优先级已经失去了大部分的价值。它们是从Firebase有 orderByChild 查询之前的剩余工件。如果您今天开始使用Firebase项目,则应使用 orderByChild ,而不是依赖优先级。


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.

解决方案

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.

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

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