Created
March 12, 2023 14:46
-
-
Save anioutkazharkova/406db186070a99d89354704693dc1db9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Создание | |
suspend fun createPost(postItem: PostItem) { | |
val currentUser = FirebaseAuthHelper.instance.currentUser | |
postItem.userId = currentUser?.uid.orEmpty() | |
postItem.userName = currentUser?.displayName.orEmpty() | |
val collection = FirebaseFirestore.getInstance().collection("posts") | |
val document = collection.document(postItem.uuid) | |
document.set(postItem).await() | |
} | |
//Редактирование | |
suspend fun editPost(postItem: PostItem) { | |
postItem.editor = FirebaseAuthHelper.instance.currentUser?.uid.toString() | |
val collection = FirebaseFirestore.getInstance().collection("posts") | |
val document = collection.document(postItem.uuid) | |
document.set(postItem).await() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment