Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Curl 使用orderByChild和equalTo卷曲Firebase?_Curl_Firebase - Fatal编程技术网

Curl 使用orderByChild和equalTo卷曲Firebase?

Curl 使用orderByChild和equalTo卷曲Firebase?,curl,firebase,Curl,Firebase,我正在尝试使用RESTAPI查询Firebase(目前仅使用curl) 我尝试使用返回结果的orderByChild进行查询,但它们似乎没有排序 curl -k 'https://shining-fire-6711.firebaseio.com/todos.json?orderByChild="name"' 我还尝试将orderByChild与equalTo子句结合使用,但这只会返回一个错误orderBy必须在定义其他查询参数时定义 curl -k 'https://shining-fire-

我正在尝试使用RESTAPI查询Firebase(目前仅使用curl)

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

curl -k 'https://shining-fire-6711.firebaseio.com/todos.json?orderByChild="name"'
我还尝试将
orderByChild
equalTo
子句结合使用,但这只会返回一个错误
orderBy必须在定义其他查询参数时定义

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

开发不需要索引,除非您使用其余的索引 API。实时客户端库可以执行即席查询,而无需 指定索引。性能将随着您查询的数据而降低 增长,因此在启动应用程序之前添加索引非常重要 您需要查询大量数据

这份文件藏在某个很深的地方,我花了好几个小时才找到它

此外,执行一些示例(从中获得)。我尝试在控制台上运行以下代码

curl'https://dinosaur-facts.firebaseio.com/dinosaurs.json?orderBy=“高度”&print=pretty'

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

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

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

Firebase的RESTAPI返回一个JSON对象。由于JSON对象中键的顺序是不确定的,因此结果也是无序的。因此,RESTAPI中的orderBy操作仅用于限制返回的结果,您必须(重新)在客户端对它们进行排序。文档在这一点上“不是很清楚”,我们打算在不久的将来解决这个问题。上一次查询的可能重复应该使用
orderBy
而不是
orderByChild
(这不是REST API的现有参数)。所以
curl-k'https://shining-fire-6711.firebaseio.com/todos.json?orderBy=“name”&equalTo=“c”
可以工作,但您需要为rules.json添加索引。很抱歉,在RESTAPI中,哪里可以找到用于
orderByChild
的文档?只有
orderBy
querysure,它忽略所有未知的查询参数