Firebase上的通配符查询? [英] Wildcard query on Firebase?

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

问题描述

有可能在Firebase上进行通配符查询吗?例如:

  https://foo.firebaseio.com/person.json?orderBy=name& equalTo = Lun *


解决方案

我以为别人可能会感兴趣。你可以伪造一个通配符来搜索诸如 foo * 之类的东西(所以基本上你可以搜索以指定字符串开头的值)。

对于iOS& Swift它看起来像这样:
$ b $ pre $ code> dbReference.child(person)。queryOrdered(byChild:name)。queryStarting (atValue:foo)。queryEnding(atValue:foo\u {f8ff})。 \(String(descriptions:snapshot.value)))
}

是使用名称属性的开始和结束值,其中结尾键等于开始+ Unicode范围中的非常高的代码点。因为它是在Unicode之后的大部分常规字符之后,查询匹配所有以 foo 开始的值。


Is it possible to do wildcard queries on Firebase? For example:

https://foo.firebaseio.com/person.json?orderBy="name"&equalTo="Lun*"

解决方案

I know it's been a while but I thought that others might be interested. You can "fake" a wildcard search for things like foo* (so basically you can search for values beginning with a specified string).

For iOS & Swift it would look like this:

dbReference.child("person").queryOrdered(byChild: "name").queryStarting(atValue: "foo").queryEnding(atValue: "foo\u{f8ff}").observe(.childAdded) { (snapshot: FIRDataSnapshot) in
    print("\(snapshot.key) - \(String(describing: snapshot.value))")
}

What this does is using a start and end values for name property where the end key is equal to the start + 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 foo.

这篇关于Firebase上的通配符查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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