【问题标题】:What is the best method to exclude data and query parts of data in a Swift Firebase query?在 Swift Firebase 查询中排除数据和查询部分数据的最佳方法是什么?
【发布时间】:2016-06-20 09:58:57
【问题描述】:

我正在从 Firebase 查询用户,并想知道查询除当前 ref.authData.uid 之外的所有用户的最佳方法。像这样解析它的读取......

query?.whereKey("username", notEqualTo: PFUser.currentUser()!.username!)
query?.whereKey("username", containsString: self.searchTXTFLD.text)

另外,有没有类似于 Parse 的 containsString 的 Firebase 查询类型?

【问题讨论】:

  • 正如弗兰克在他的回答中所说,在字符串中没有搜索。但是,您可以滚动自己的Searching in Firebase without server side code。在那里查看我的答案。至于省略当前用户,有办法做到这一点,但这取决于你是在做查询还是观察节点。如果我们有更多关于您所追求的数据,我们可以提供更好的方向。

标签: database swift firebase


【解决方案1】:

无法仅从 Firebase 中检索符合特定条件的项目。您必须检索所有项目并在客户端排除有问题的项目。另见is it possible query data that are not equal to the specified condition?

Firebase 查询也没有 contains 运算符。这个之前已经讲过很多次了,比如这个问题:Firebase query - Find item with child that contains string

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-19
    • 2012-07-20
    • 1970-01-01
    • 2016-04-27
    • 1970-01-01
    • 1970-01-01
    • 2012-05-25
    • 2021-01-28
    相关资源
    最近更新 更多