Reputation: 1136
I have a data class of A with a set of strings as the property. How do I put it into the Firestore?
data class A(
val str: set<String> = emptySet()
)
Upvotes: 0
Views: 43
Reputation: 599131
A mathematical set is best mapped to an array in Cloud Firestore, which you then manipulate with the array-union
and array-remove
operators, and query using array-contains
. These operators ensure that each value can occur only once in the array, which is required to make it mimic a set.
See:
Upvotes: 1