/
Jojer
/
RepTrack
Обзор
Документация
Войти
/
Jojer
/
RepTrack
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
app/src/main/java/com/example/reptrack/data/backup/FirebaseBackupDataSource.kt
65 строк
2 KB
MaximOdincov
refactoring files organization
08 фев 2026, 11:41
08 фев 2026, 11:41
56aa20a
Код
Авторство
О чём код?
package com.example.reptrack.data.backup import com.google.firebase.firestore.FirebaseFirestore import com.google.firebase.firestore.QuerySnapshot import com.google.firebase.firestore.DocumentSnapshot import kotlinx.coroutines.tasks.await class FirebaseBackupDataSource( private val firestore: FirebaseFirestore ) { suspend fun listDocuments( userId: String, entityType: String ): QuerySnapshot { return firestore .collection("users") .document(userId) .collection(entityType) .get() .await() } suspend fun getDocument( userId: String, entityType: String, entityId: String ): DocumentSnapshot? { return firestore .collection("users") .document(userId) .collection(entityType) .document(entityId) .get() .await() } suspend fun uploadDocument( userId: String, entityType: String, entityId: String, data: Map<String, Any?> ) { firestore .collection("users") .document(userId) .collection(entityType) .document(entityId) .set(data, com.google.firebase.firestore.SetOptions.merge()) .await() } suspend fun deleteDocument( userId: String, entityType: String, entityId: String ) { firestore .collection("users") .document(userId) .collection(entityType) .document(entityId) .delete() .await() } }