使用 orderByChild 和 equalTo 来冰壶 Firebase?

标签 curl firebase

我正在尝试使用 REST API 来查询 Firebase(目前仅使用curl)。

我尝试使用返回结果的 orderByChild 进行查询,但它们似乎没有排序。

curl -k 'https://shining-fire-6711.firebaseio.com/todos.json?orderByChild="name"'

我还尝试将 orderByChildequalTo 子句结合使用,但这只会返回错误定义其他查询参数时必须定义 orderBy

curl -k 'https://shining-fire-6711.firebaseio.com/todos.json?orderByChild="name"&equalTo="c"'

最佳答案

根据Firebase Document :

Indexes are not required for development unless you are using the REST API. The realtime client libraries can execute ad-hoc queries without specifying indexes. Performance will degrade as the data you query grows, so it is important to add indexes before you launch your app if you anticipate querying a large set of data.

该文档隐藏在某个很深的地方,我花了几个小时才找到它。

另外执行一些示例(从 another Firebase Document 获得)。我尝试在控制台上运行以下代码

curl 'https://dinosaur-facts.firebaseio.com/dinosaurs.json?orderBy="height"&print=pretty'

它返回一些数据。这是返回值的一部分

{
  "linhenykus" : {
    "appeared" : -85000000,
    "height" : 0.6,
    "length" : 1,
    "order" : "theropoda",
    "vanished" : -75000000,
    "weight" : 3
  }
}

这表明您不需要使用参数 orderByChild,使用 orderBy 就可以了。

关于使用 orderByChild 和 equalTo 来冰壶 Firebase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31420121/

相关文章:

java - 将正文请求 POST 中的多个文件上传到 Spring Restful API

php - 安全地更新证书颁发机构证书

firebase - 更改 Firebase 的时区 (UTC)

java - 无法使用 Firebase 云消息传递发送通知

firebase - Firestore 使用文档引用获取字段值

php - 287 不是有效的 cURL 句柄资源

bash - 为什么对 REST 服务的 bash/CURL 调用会给出与参数不一致的结果?

jQuery - 单击链接后将 html 文件加载到 div 中

firebase - Firebase 托管有什么用?

php - 为什么我需要 Laravel 的 Docker?