Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class FirestoreRepository {
val TAG = "FIREBASE_REPOSITORY"
var firestoreDB = FirebaseFirestore.getInstance()
var user = FirebaseAuth.getInstance().currentUser
// save address to firebase
fun saveAddressItem(addressItem: AddressItem): Task<Void> {
//var
var documentReference = firestoreDB.collection("users").document(user!!.email.toString())
.collection("saved_addresses").document(addressItem.addressId)
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")
.document(addressItem.addressId)
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.