MrShoot
MrShoot

Reputation: 863

Index Firestore multiple values

imagine I have an array that looks like this

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

Is it possible to create firestore index that looks something like this...

categories.* descending: true

Or do I have to create an index for every possible value inside categories?

Thanks a lot for the help.

Upvotes: 0

Views: 98

Answers (1)

Jake
Jake

Reputation: 2216

Yes. Use Subcollections.

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

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

Upvotes: 1

Related Questions