Firebase上的通配符查询? [英] Wildcard query on 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屋!