.indexOn Firebase iOS

时间:2016-04-24 19:50:44

标签: xcode firebase firebase-realtime-database

这是数据结构布局。我有多个小组,每组下都有多笔付款

{
  "RE_PAYMENTS" : {
"AF04BDB4-6AF4-43F1-A084-D215AD0C992D" : {  
  "B73FBFB1-2615-4F42-A7C6-3CA4B2B4BCDF" : { 
    "PAYMENT_DETAIL" : {
      "paymentAmount" : 20,
      "paymentCurrency" : "USD",
      "paymentDate" : "1461525157.150915"
    }
  },
  "B8B0FDF3-4458-4AE2-B1A0-9DCD8ACFF422" : {
    "PAYMENT_DETAIL" : {
      "paymentAmount" : 40,
      "paymentCurrency" : "USD",
      "paymentDate" : "1461525392.178588"
    }
   }
  }
 }
}

从上面的结构" AF04B ......"是groupId,下面会有多个付款组。

以下是我编写规则的方式。

enter image description here

我仍然不断收到Xcode警告

[Firebase] Using an unspecified index. Consider adding ".indexOn": "PAYMENT_DETAIL/paymentDate" at /RE_PAYMENTS/AF04BDB4-6AF4-43F1-A084-D215AD0C992D to your security rules for better performance

我已经按照文档进行操作,并且我试图尽可能保持结构平坦。有关解决此indexOn问题的任何提示?我无法使用索引规则对groupId或paymentId进行硬编码。

以下是触发此警告的代码(eventType为FEventTypeChildAdded或FEventTypeChildChanged或FEventTypeChildRemoved)

FQuery* query = [self queryRefForPaymentsForGroup:groupId];
[query observeEventType:eventType withBlock:^(FDataSnapshot *snapshot)
 {}

查询创建为

// I have just pasted the value here but the path is created using 'childByAppendingPath'
Firebase *groupRef = @"https://xxxxxxxx.firebaseio.com/RE_PAYMENTS/AF04BDB4-6AF4-43F1-A084-D215AD0C992D";   

FQuery* query = [[[groupRef queryOrderedByChild:@"PAYMENT_DETAIL/paymentDate"] queryStartingAtValue:startDateQueryString] queryEndingAtValue:endDateQueryString];

以下是查询的Xcode控制台

enter image description here

我尝试做的只是查询一组日期内某组下的付款清单。

0 个答案:

没有答案