ios - 索引 Firestore 多个值

标签 ios swift google-cloud-firestore

假设我有一个看起来像这样的数组

postedAt: 241242
categories:
- gaming: true
- history: true
- sports: true

是否可以创建看起来像这样的 firestore 索引...

类别。*降序:真

或者我是否必须为类别中的每个可能值创建一个索引?

非常感谢您的帮助。

最佳答案

是的。 Use Subcollections .

let data: [String: Any] = [
    "postedAt": 241242,
    "categories": [
        "gaming": true,
        "history": true,
        "sports": true,
    ]
]

Firestore.firestore().collection("users/data").addDocument(data)

关于ios - 索引 Firestore 多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49471011/

相关文章:

ios - 检查 MIC 是否被锁定或被其他 iOS 应用程序使用

iphone - Storyboard自动布局 : "trailing space to container" vs "bottom space to bottom layout"

ios - 从 UITableView 中删除项目后索引超出范围

ios - 在整洁的架构中使用 NSFetchedResultsController

ios - 使用 AFNetworking 的带闭包的 Swift 完成 block

ios - iPhone 模拟器立即崩溃并显示 EXC_BAD_ACCESS

ios - iOS8 中的扩展 - 由于没有系统应用程序而终止

javascript - Firestore 未捕获类型错误 : doc. 数据不是函数

firebase - 如何为使用 Cloud Firestore 的 Flutter 应用设置安全规则?

android - 火存储 : PERMISSION_DENIED: Missing or insufficient permissions