【发布时间】:2015-03-19 13:12:40
【问题描述】:
我正在使用 Geofire 在某个区域进行 circleQuery。设置好观察员后,我将返回位置,但是,使用该位置时,我还会返回“使用未指定的索引。考虑添加“.indexOn”:“g””
我的 geofire 数据库看起来像这样 karmadots/geofire/{events}
"rules": {
"karmadots": {
".read": true,
".write": true,
"geofire": {
"$events": {
".indexOn": ["g"]
}
}
}
我也试过了:
"rules": {
"karmadots": {
".read": true,
".write": true,
"geofire": {
".indexOn": ["g"]
}
}
}
两者都不会使消息消失。还有什么我可以尝试阅读或尝试作为示例的吗?
感谢您的帮助。
编辑:
我的路径是 xxxxx.firebaseio.com/karmadots/geofire/{keys}
我是这样查询的:
func setupListeners(query: GFQuery){
// Event is in initial area or entered area
query.observeEventType(GFEventTypeKeyEntered, withBlock: { (key: String!, location: CLLocation!) in
println("Key '\(key)' entered the search area and is at location '\(location)'\n")
})
// Event left area
query.observeEventType(GFEventTypeKeyExited, withBlock: { (key: String!, location: CLLocation!) in
println("Key '\(key)' left the search area\n")
})
// Event moved but is still in area
query.observeEventType(GFEventTypeKeyMoved, withBlock: { (key: String!, location: CLLocation!) in
println("Key '\(key)' moved in the search area and is at location '\(location)'\n")
})
}
【问题讨论】:
-
后者看起来更可能是正确的。但可以肯定的是,你能告诉我们你运行的查询吗?最好显示从根到 geofire 查询中使用的实际事件的整个路径。
-
@FrankvanPuffelen 我已经编辑了我的原始帖子并包含了查询。不确定我的整个路径是否就是你的意思。
-
嗯...当我对其运行常规 Firebase 查询时,我没有收到任何错误:
new Firebase('https://karmadots.firebaseio.com/karmadots/geofire/').orderByChild('g').startAt("9q8yywcp39").endAt("9q8yywcp39").limitToFirst(3).once('value', function(s) { console.log(s.val()); })。这基本上也是 GeoFire 所做的。 -
子订单是否发生在 karmadots/geofire 路径下?在您可以通过 g 订购之前是否还有一个目录,即 karmadots/geofire/{keys}/g。其次,我的查询是否添加了 orderByChild()?还是 .indexOn 添加的?
-
当我从 ".indexOn": ["g"] 中删除括号并只使用 ".indexOn" : "g" 时,它起作用了。
标签: firebase firebase-security