两个纬度之间的Firebase查询

时间:2016-06-27 01:33:12

标签: swift firebase firebase-realtime-database

我无法从我的数据库接收数据,其中帖子的纬度在用户当前纬度的+/- 0.1之内。

我的Firebase树如下:

C:\Users\%USER%\Miniconda\lib\site-packages\paramiko\hostkeys.pyc in load(self, filename)
     93         :raises IOError: if there was an error reading the file
     94         """
---> 95         with open(filename, 'r') as f:
     96             for lineno, line in enumerate(f, 1):
     97                 line = line.strip()

IOError: [Errno 2] No such file or directory: 'C:\\Users\\%USER%/.ssh/known_hosts'

} }

纬度和经度属于{ "person" : { "ss" : { "email" : "contact@surrogatesystems.com", "username" : "Surrogate Systems" }, "CZ6Ujxsm0SXybtcLBthXOpG3YgU2" : { "email" : "ljahnke9@gmail.com", "username" : "Logan Jahnke" } }, "prayers" : { "p0" : { "contents" : "For understanding of Firebase as we build the Surge: Prayer Sharing application.", "likes" : 100, "personid" : "ss", "posted" : "2016-06-21 20:15:00", "latitude" : 33.9441737581188, "longitude" : -83.3843067012304 }, "p1" : { "contents" : "This is a test prayer.", "likes" : 0, "personid" : "CZ6Ujxsm0SXybtcLBthXOpG3YgU2", "posted" : "2016-06-21 20:00:00", "latitude" : 33.9441737581188, "longitude" : -83.3843067012304 }, "p2" : { "contents" : "My prayer request is that every child in Los Andes, Panama know the love of Jesus Christ. I also pray for their families and their friends. I pray that their education runs smoothly and that they learn the English they desire to know. I pray that we made an impact on them.", "likes" : 0, "personid" : "CZ6Ujxsm0SXybtcLBthXOpG3YgU2", "posted" : "2016-06-21 20:00:00", "latitude" : 35.3341737581184, "longitude" : -81.3843067012304 } 类型。我目前的疑问是:

Double

这会在调用快照时返回NSNull,即使我的系统中有符合条件的entires。

我的电话有什么问题,我该如何解决?

1 个答案:

答案 0 :(得分:0)

我看到了同样的行为。我通过插入对queryOrderedByChild的调用来获得预期的结果:

    let query = ref.child("prayers")
                .queryOrderedByChild("latitude")
                .queryStartingAtValue(lat - 0.1)
                .queryEndingAtValue(lat + 0.1)
                .queryLimitedToFirst(50)
                .observeEventType(.ChildAdded, withBlock: { (snapshot) in
                    print(snapshot)
                })