blog icon indicating copy to clipboard operation
blog copied to clipboard

How to query document id in array in Firestore

Open onmyway133 opened this issue 3 years ago • 0 comments

Supposed we have Book object

struct Book: Identifiable, Codable, Hashable {
    @DocumentID var id: String?
}

We should use FieldPath instead of id for query

let booksRef: CollectionReference = ...
let ids: [String] = ...

booksRef
    .whereField(
        FieldPath.documentID(),
        in: ids
    )

onmyway133 avatar Nov 28 '21 22:11 onmyway133