Skip to content

Commit 7af9843

Browse files
authored
removed DocumentSnapshot.dataMap() (#250)
1 parent 9ce9222 commit 7af9843

File tree

5 files changed

+0
-34
lines changed
  • firebase-firestore/src

5 files changed

+0
-34
lines changed

firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

-3
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,6 @@ actual class DocumentSnapshot(val android: com.google.firebase.firestore.Documen
415415
actual fun <T> data(strategy: DeserializationStrategy<T>, serverTimestampBehavior: ServerTimestampBehavior): T =
416416
decode(strategy, android.getData(serverTimestampBehavior.toAndroid()))
417417

418-
actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map<String, Any?> =
419-
android.getData(serverTimestampBehavior.toAndroid()) ?: emptyMap()
420-
421418
actual inline fun <reified T> get(field: String, serverTimestampBehavior: ServerTimestampBehavior): T =
422419
decode(value = android.get(field, serverTimestampBehavior.toAndroid()))
423420

firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ expect class DocumentSnapshot {
196196
inline fun <reified T: Any> data(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): T
197197
fun <T> data(strategy: DeserializationStrategy<T>, serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): T
198198

199-
fun dataMap(serverTimestampBehavior: ServerTimestampBehavior = ServerTimestampBehavior.NONE): Map<String, Any?>
200-
201199
val exists: Boolean
202200
val id: String
203201
val reference: DocumentReference

firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt

-20
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ class FirebaseFirestoreTest {
160160
val pendingWritesSnapshot = deferredPendingWritesSnapshot.await()
161161
assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites)
162162
assertNull(pendingWritesSnapshot.get<Double?>("time", ServerTimestampBehavior.NONE))
163-
assertNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.NONE)["time"])
164163
}
165164

166165
@Test
@@ -181,7 +180,6 @@ class FirebaseFirestoreTest {
181180
val pendingWritesSnapshot = deferredPendingWritesSnapshot.await()
182181
assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites)
183182
assertNotNull(pendingWritesSnapshot.get<Double?>("time", ServerTimestampBehavior.ESTIMATE))
184-
assertNotNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.ESTIMATE)["time"])
185183
assertNotEquals(0.0, pendingWritesSnapshot.data(FirestoreTest.serializer(), ServerTimestampBehavior.ESTIMATE).time)
186184
}
187185

@@ -203,7 +201,6 @@ class FirebaseFirestoreTest {
203201
val pendingWritesSnapshot = deferredPendingWritesSnapshot.await()
204202
assertTrue(pendingWritesSnapshot.metadata.hasPendingWrites)
205203
assertNull(pendingWritesSnapshot.get<Double?>("time", ServerTimestampBehavior.PREVIOUS))
206-
assertNull(pendingWritesSnapshot.dataMap(ServerTimestampBehavior.PREVIOUS)["time"])
207204
}
208205

209206
@Test
@@ -223,23 +220,6 @@ class FirebaseFirestoreTest {
223220
assertEquals("AutoId", resultDoc.get("prop1"))
224221
}
225222

226-
@Test
227-
fun testDataMap() = runTest {
228-
val doc = Firebase.firestore
229-
.collection("testDataMap")
230-
.document
231-
232-
doc.set(FirestoreTest.serializer(), FirestoreTest("dataMap", 123.45))
233-
234-
val resultDoc = Firebase.firestore
235-
.collection("testDataMap")
236-
.document(doc.id)
237-
.get()
238-
239-
assertEquals(true, resultDoc.exists)
240-
assertEquals(mapOf("prop1" to "dataMap", "time" to 123.45), resultDoc.dataMap())
241-
}
242-
243223
private suspend fun setupFirestoreData() {
244224
Firebase.firestore.collection("FirebaseFirestoreTest")
245225
.document("one")

firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

-6
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,6 @@ actual class DocumentSnapshot(val ios: FIRDocumentSnapshot) {
388388
return decode(strategy, data?.mapValues { (_, value) -> value?.takeIf { it !is NSNull } })
389389
}
390390

391-
actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map<String, Any?> =
392-
ios.dataWithServerTimestampBehavior(serverTimestampBehavior.toIos())
393-
?.map { (key, value) -> key.toString() to value?.takeIf { it !is NSNull } }
394-
?.toMap()
395-
?: emptyMap()
396-
397391
actual inline fun <reified T> get(field: String, serverTimestampBehavior: ServerTimestampBehavior): T {
398392
val value = ios.valueForField(field, serverTimestampBehavior.toIos())?.takeIf { it !is NSNull }
399393
return decode(value)

firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

-3
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ actual class DocumentSnapshot(val js: firebase.firestore.DocumentSnapshot) {
393393
actual fun <T> data(strategy: DeserializationStrategy<T>, serverTimestampBehavior: ServerTimestampBehavior): T =
394394
rethrow { decode(strategy, js.data(getTimestampsOptions(serverTimestampBehavior))) }
395395

396-
actual fun dataMap(serverTimestampBehavior: ServerTimestampBehavior): Map<String, Any?> =
397-
rethrow { mapOf(js.data(getTimestampsOptions(serverTimestampBehavior)).asDynamic()) }
398-
399396
actual inline fun <reified T> get(field: String, serverTimestampBehavior: ServerTimestampBehavior) =
400397
rethrow { decode<T>(value = js.get(field, getTimestampsOptions(serverTimestampBehavior))) }
401398

0 commit comments

Comments
 (0)