Reputation: 983
Is there a simple way to convert something like this
data class Pet (
val owner: Owner = Owner()
)
data class Owner (
val name: String? = null,
val email: String? = null
)
to a Firestore collection automatically?
This doesn't work for me:
val owner = Owner("Joe", "[email protected]")
val pet = Pet("Petty", owner)
db.collection("pets").add(pet)
Upvotes: 1
Views: 117
Reputation: 317657
It's not possible. When you add()
an object, it is converted to a single document. If you need to create multiple documents, then you will also need multiple calls to add()
or set()
, each with the data to put in the document.
Upvotes: 2