我正在尝试查询 firebase 上的数据以查找其值包含字符串的一部分的子级。所以假设值是“apple”,如果我搜索“app”,我会返回该记录。我意识到有人问过这个问题,但我读过的所有答案都指向 firebase 将集成此功能这一事实……差不多 3 年过去了,我似乎找不到任何东西。
最佳答案
在你的例子中......
如果您要严格查询以字符串开头的数据,在本例中为“app”,则可以轻松完成:
queryStartingAtValue("app").queryEndingAtValue("app\u{f8ff}")
有关详细信息,请参阅写得很好但现在已成为遗产的 Firebase Guide To Retrieving Data
然后向下滚动到“范围查询”部分
为了完整性:
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. (app in this case)
关于swift - 包含值的 Firebase 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38538863/