接收具有查询和键范围的项目

时间:2017-03-01 16:07:41

标签: ios swift firebase firebase-realtime-database batch-fetching

这里结构简单:

$countryCode
 -autoid13
  -category: vehicles
 -autoid12
  -category: sport
 -autoid11
  -category: food
 -autoid10
  -category: sport
 -autoid9
  -category: vehicles
 -autoid8
  -category: food
 -autoid7
  -category: sport
 -autoid6
  -category: sport

我的问题是如何才能获取具有类别的项目:id7-id11项目之间的运动? / autoid键由firebase管理

1 个答案:

答案 0 :(得分:0)

这是怎么做的

countryCode
 -autoid13
  -category: vehicles_13
 -autoid12
  -category: sport_12
 -autoid11
  -category: food_11
 -autoid10
  -category: sport_10
 -autoid9
  -category: vehicles_09
 -autoid8
  -category: food_08
 -autoid7
  -category: sport_07
 -autoid6
  -category: sport_06

和伪代码

   ref.orderBy("category")
      .queryStartingAtValue("sport_07")
      .queryEndingAtValue("sport_11")

将返回

 -autoid7
  -category: sport_07
 -autoid10
  -category: sport_10