Skip to content

Instantly share code, notes, and snippets.

@a914-gowtham
Last active September 18, 2021 06:31
Show Gist options
  • Save a914-gowtham/632886cd49ff445b4eb7582e2c86c372 to your computer and use it in GitHub Desktop.
Save a914-gowtham/632886cd49ff445b4eb7582e2c86c372 to your computer and use it in GitHub Desktop.
fun insertUser(){
val mobileNumber= MobileNumber("+91","9876543210")
val profile = UserProfile(
uId= userId,
image = "https://i.pravatar.cc/150?img=2",
userName = "otis",
mobile = mobileNumber,
token = "el3LZrv0QmK5k-vjoO970:APA91bF8XKRqqTmf2n7E2PUrVDaxvhxq3WAIwQ5sHqLkwGbiICkebrCpkpwJvrVrvcJiDgaeLndJQwJDWvv2ad-W0SGDpDyuYgrQGFo5eDQSvce20gS1Q5ijmkD-QmzBAgFoRVaDi2u",
)
val db = FirebaseFirestore.getInstance()
db.collection("Users").document(profile.uid)
.set(profile, SetOptions.merge())
.addOnSuccessListener { Log.d(TAG, "DocumentSnapshot successfully written!") }
.addOnFailureListener { e -> Log.w(TAG, "Error writing document", e) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment