From a3cc42ddeca504b4cac054605fb9ffbc75ac49f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Owodzin=CC=81?= Date: Tue, 2 Nov 2021 23:38:56 +0000 Subject: [PATCH] removed DocumentSnapshot.dataMap() --- .../gitlive/firebase/firestore/firestore.kt | 3 --- .../gitlive/firebase/firestore/firestore.kt | 2 -- .../gitlive/firebase/firestore/firestore.kt | 20 ------------------- .../gitlive/firebase/firestore/firestore.kt | 6 ------ .../gitlive/firebase/firestore/firestore.kt | 3 --- 5 files changed, 34 deletions(-) diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 970bea996..115d4a114 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -415,9 +415,6 @@ actual class DocumentSnapshot(val android: com.google.firebase.firestore.Documen actual fun data(strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior): T = decode(strategy, android.getData(serverTimestampBehavior.toAndroid())) - actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map = - android.getData(serverTimestampBehavior.toAndroid()) ?: emptyMap() - actual inline fun get(field: String, serverTimestampBehavior: ServerTimestampBehavior): T = decode(value = android.get(field, serverTimestampBehavior.toAndroid())) diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 12565196d..366b416b2 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -196,8 +196,6 @@ expect class DocumentSnapshot { inline fun data(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): T fun data(strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): T - fun dataMap(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Map - val exists: Boolean val id: String val reference: DocumentReference diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 65d2ff576..f48ae582d 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -160,7 +160,6 @@ class FirebaseFirestoreTest { val pendingWritesSnapshot = deferredPendingWritesSnapshot.await() assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites) assertNull(pendingWritesSnapshot.get("time", ServerTimestampBehavior.NONE)) - assertNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.NONE)["time"]) } @Test @@ -181,7 +180,6 @@ class FirebaseFirestoreTest { val pendingWritesSnapshot = deferredPendingWritesSnapshot.await() assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites) assertNotNull(pendingWritesSnapshot.get("time", ServerTimestampBehavior.ESTIMATE)) - assertNotNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.ESTIMATE)["time"]) assertNotEquals(0.0, pendingWritesSnapshot.data(FirestoreTest.serializer(), ServerTimestampBehavior.ESTIMATE).time) } @@ -203,7 +201,6 @@ class FirebaseFirestoreTest { val pendingWritesSnapshot = deferredPendingWritesSnapshot.await() assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites) assertNull(pendingWritesSnapshot.get("time", ServerTimestampBehavior.PREVIOUS)) - assertNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.PREVIOUS)["time"]) } @Test @@ -223,23 +220,6 @@ class FirebaseFirestoreTest { assertEquals("AutoId", resultDoc.get("prop1")) } - @Test - fun testDataMap() = runTest { - val doc = Firebase.firestore - .collection("testDataMap") - .document - - doc.set(FirestoreTest.serializer(), FirestoreTest("dataMap", 123.45)) - - val resultDoc = Firebase.firestore - .collection("testDataMap") - .document(doc.id) - .get() - - assertEquals(true, resultDoc.exists) - assertEquals(mapOf("prop1" to "dataMap", "time" to 123.45), resultDoc.dataMap()) - } - private suspend fun setupFirestoreData() { Firebase.firestore.collection("FirebaseFirestoreTest") .document("one") diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 5d928c290..02dfb91c5 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -388,12 +388,6 @@ actual class DocumentSnapshot(val ios: FIRDocumentSnapshot) { return decode(strategy, data?.mapValues { (_, value) -> value?.takeIf { it !is NSNull } }) } - actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map = - ios.dataWithServerTimestampBehavior(serverTimestampBehavior.toIos()) - ?.map { (key, value) -> key.toString() to value?.takeIf { it !is NSNull } } - ?.toMap() - ?: emptyMap() - actual inline fun get(field: String, serverTimestampBehavior: ServerTimestampBehavior): T { val value = ios.valueForField(field, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull } return decode(value) diff --git a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index c078ccde3..fadb1a6b2 100644 --- a/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -393,9 +393,6 @@ actual class DocumentSnapshot(val js: firebase.firestore.DocumentSnapshot) { actual fun data(strategy: DeserializationStrategy, serverTimestampBehavior: ServerTimestampBehavior): T = rethrow { decode(strategy, js.data(getTimestampsOptions(serverTimestampBehavior))) } - actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map = - rethrow { mapOf(js.data(getTimestampsOptions(serverTimestampBehavior)).asDynamic()) } - actual inline fun get(field: String, serverTimestampBehavior: ServerTimestampBehavior) = rethrow { decode(value = js.get(field, getTimestampsOptions(serverTimestampBehavior))) }