Is it possible to create a subcollection within a document by using iOS SDK? I can't find any appropriate method on API and documentation doesn't provide any guides.
As a general rule, you don't explicitly "create" collections. Instead, you create documents and, if you've specified them as belonging to a collection that does not yet exist, then that collection will be created along the way.
So if you have a /users/jane document and want to add a history subcollection, you basically do this by creating the first document you want to appear in that subcollection -- i.e. something like:
Firestore.firestore().collection("users/jane/history").addDocument(historyData)
I believe this would work, too:
Firestore.firestore().document("users/jane/history/20171105")setData(historyData)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With