我正在使用Firebase REST API来获取我的数据。我正在获取类似
的数据[ {
"date_time" : "2018-01-03 03:30:00",
"domestic" : "0",
"f_key" : "",
"id" : 2,
"international" : "1",
"league" : "0",
"match_number" : "One-day practice match",
"men" : "1",
"odi" : "1",
"result" : "Pakistan won by 120 runs",
"series_name" : "Pakistan tour of New Zealand, 2018",
"status" : "2",
"t1_short_name" : "NZ",
"t20" : "0",
"t2_short_name" : "PAK",
"team1" : "New Zealand",
"team1_flag" : "https://storage.googleapis.com/ce_flags/nz.png",
"team2" : "Pakistan",
"team2_flag" : "https://storage.googleapis.com/ce_flags/pak.png",
"test" : "0",
"venue" : "Saxton Oval, Nelson",
"women" : "0"
}, {
"date_time" : "2018-01-03 03:30:00",
"domestic" : "0",
"f_key" : "",
"id" : 159,
"international" : "1",
"league" : "0",
"match_number" : "One-day practice match",
"men" : "1",
"odi" : "1",
"result" : "Pakistan won by 120 runs",
"series_name" : "Pakistan tour of New Zealand, 2018",
"status" : "2",
"t1_short_name" : "NZ",
"t20" : "0",
"t2_short_name" : "PAK",
"team1" : "New Zealand",
"team1_flag" : "https://storage.googleapis.com/ce_flags/nz.png",
"team2" : "Pakistan",
"team2_flag" : "https://storage.googleapis.com/ce_flags/pak.png",
"test" : "0",
"venue" : "Saxton Oval, Nelson",
"women" : "0"
} ]
但是当我尝试对它们进行分页时,我无法正常使用
https://fir-resttest-4e895.firebaseio.com/Fixtures/All.json?orderBy=%22date_time%22&limitToFirst=2&startAfter=10&print=pretty
我如何在这里使用分页,请帮助我解决这个问题。
谢谢
答案 0 :(得分:0)
Firebase数据库查询不像以前那样支持offset参数。
您为startAt
传递的值必须是orderBy
中具有的属性的类型/格式的值。由于您订购的是date_time
,因此startAt
的值必须是有效的date_time
:
这将为您提供从2018-01-03 03:30:00
开始的所有项目。
orderBy="date_time"&limitToFirst=2&startAt="2018-01-03 03:30:00"
还要注意,该参数名为startAt
,而不是startAfter
。
您的数据集的一些示例:
startAt="2018-06-01 20:30:00"
startAt="2018-06-01"
(因此您也可以从子字符串开始)