Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class FirestoreRepository {
var firestoreDB = FirebaseFirestore.getInstance()
var user = FirebaseAuth.getInstance().currentUser
// save address to firebase
fun saveAddressItem(addressItem: AddressItem): Task<Void> {
var documentReference = firestoreDB.collection("users").document(user!!.email.toString())
return documentReference.set(addressItem)
// get saved addresses from firebase
fun getSavedAddress(): CollectionReference {
var collectionReference = firestoreDB.collection("users/${user!!.email.toString()}/saved_addresses")
return collectionReference
fun deleteAddress(addressItem: AddressItem): Task<Void> {
var documentReference = firestoreDB.collection("users/${user!!.email.toString()}/saved_addresses")
return documentReference.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.