here is my code: override suspend fun updateDocume...
# android
f
here is my code: override suspend fun updateDocument( productId: String, updates: Map<String, Any> ): Resource<Boolean> { return withContext(Dispatchers.IO) { try { val documentSnapshot = db.collection(INVENTORY) .document(productId) .get() .await() if (documentSnapshot.exists()) { Timber.tag(INVENTORY_TAG).d("Document exists") db.collection(INVENTORY) .document(productId) .update(updates) .await() Resource.Success(true) } else { Timber.tag(INVENTORY_TAG).e("Document does not exist") Resource.Error(Exception("Document with ID $productId does not exist")) } } catch (e: Exception) { Timber.tag(INVENTORY_TAG).e(e) Resource.Error(e) } } }
🧵 5