Is there any way to add a document to firestore collection with custom id on Swift Language, not the id generated by firestore engine.
Thanks in advance for your responses.
Yes. Just try this:
Firestore.firestore().collection("items").document("yourId").setData(["item": "test"])
Usually you'd want the error handling:
Firestore.firestore()
.collection("companyAddress")
.document(companyID)
.setData([
"address1": a1,
"address2": a2,
"city": c
]) { [weak self] err in
guard let self = self else { return }
if let err = err {
print("err ... \(err)")
self.yourErrorAlert()
}
else {
print("saved ok")
self.proceedWithUX()
}
}
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