ios - 随机生成的 key 中包含的 Firebase 查询十六进制代码

标签 ios swift firebase firebase-realtime-database

我想从颜色十六进制代码数组中查询一个特定的 child 。

这是我的数据库结构的快照:

enter image description here

如何查询特定的十六进制代码并获取其父对象的整个数组?

最佳答案

您无法查询列表中是否存在特定值。这是 Firebase 文档建议不要在数据库中使用数组的众多原因之一。

但在这种情况下(以及我遇到的大多数情况),您可能真的不需要数组。假设您只关心用户选择的颜色。在这种情况下,您可以更有效地将颜色存储为:

palettes
    -KSmJZ....A5I
        "0x474A39": true
        "0xbA9A7C": true
        "0xDEDEDF": true
        "0x141414": true
        "0x323E35": true

关于ios - 随机生成的 key 中包含的 Firebase 查询十六进制代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39756884/

相关文章:

ios - UICollectionView 的层次结构是什么?

swift - Xcode7.3 swift项目丢失语法着色

firebase - Flutter Cloud Firestore orderBy 和 limit 问题

android - 将 Google Play 游戏与 Firebase Auth 结合使用

ios - 为什么当我触摸屏幕时我的图像没有弹出?

iOS:根据数组的顺序对文件夹中的文件进行排序

ios - 没有已知的选择器实例方法——委托(delegate)问题?

ios - 通过命令行运行单元测试 - Swift Project with cocoaPods

ios - WatchKit 菜单项未在真实设备上显示

ios - Swift Firebase 通知 "libc++abi.dylib: terminating with uncaught exception of type NSException"