Firebase indexOn登录用户到应用程序

时间:2017-06-15 03:42:33

标签: firebase firebase-realtime-database

Firebase是否允许搜索的动态索引!?

我有以下结构:

PlayerInPool: {
      12345:                                 <- PoolId
          DUmwewIfzAbfWZN4NjS8mhX82 : true   <- UserId
          LpWgezRkC6EWS0sjXEWxhFl2  : true
          etc...              
    }
}

我这样做了一个观察者:

ref.queryOrdered(byChild: (Auth.auth().currentUser?.uid)!).queryEqual(toValue: true).observe(.value, with: { snapshot in ...

当我运行应用程序时,我收到以下警告:

  

[Firebase / Database] [I-RDB034028]使用未指定的索引。   考虑添加“.indexOn”:“DUmwewIfzAbfWZN4NjS8mhX82”at   / PlayerInPool根据您的安全规则获得更好的性能

我正在尝试在Firebase的“规则”中执行以下操作

"PlayerInPool": {
  ".indexOn" : "auth.uid"
}

但它不会允许它说明:

  

保存规则时出错 - 第45行:无效密钥:auth.uid。索引必须是   .value或在有效路径上声明

我怎样才能让它发挥作用!?

  

更新评论

如果我按照建议反转结构,我会得到这个:

PlayerInPool: {
      DUmwewIfzAbfWZN4NjS8mhX82:        <- UserId                         
          12345 : true                  <- PoolId
          98765 : true
      LpWgezRkC6EWS0sjXEWxhFl2: 
          12345 : true
    }
}

我不完全确定这会改变什么!?

0 个答案:

没有答案