Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anioutkazharkova/406db186070a99d89354704693dc1db9 to your computer and use it in GitHub Desktop.
Save anioutkazharkova/406db186070a99d89354704693dc1db9 to your computer and use it in GitHub Desktop.
//Создание
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