具有部分匹配值的Firebase iOS查询数据 [英] Firebase iOS query data with partially matching value

查看:44
本文介绍了具有部分匹配值的Firebase iOS查询数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firebase queryEqualToValue将项 EQUAL 返回指定的键或值.我们如何查询 PARTIALLY MATCH 到指定键或值的项目?

Firebase queryEqualToValue returns items EQUAL to the specified key or value. How can we query for items PARTIALLY MATCH to the specified key or value?

Firebase iOS检索数据文档

推荐答案

我们可以结合使用startAt()和endAt()来限制查询的两端. 以下示例查找名称以 字母"b":

We can combine startAt() and endAt() to limit both ends of our query. The following example finds all dinosaurs whose name starts with the letter "b":

let ref = Firebase(url:"https://dinosaur-facts.firebaseio.com/dinosaurs")
ref.queryOrderedByKey().queryStartingAtValue("b").queryEndingAtValue("b\u{f8ff}")
   .observeEventType(.ChildAdded, withBlock: { snapshot in

    println(snapshot.key)
})

上面的查询中使用的f8ff字符是一个很高的代码点 在Unicode范围内.因为它是在大多数常规字符之后 Unicode,查询匹配所有以b开头的值.

The f8ff character used in the query above is a very high code point in the Unicode range. Because it is after most regular characters in Unicode, the query matches all values that start with a b.

获取数据

这篇关于具有部分匹配值的Firebase iOS查询数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆