File tree Expand file tree Collapse file tree 5 files changed +29
-4
lines changed
androidMain/kotlin/dev/gitlive/firebase/firestore
commonMain/kotlin/dev/gitlive/firebase/firestore
commonTest/kotlin/dev/gitlive/firebase/firestore
iosMain/kotlin/dev/gitlive/firebase/firestore
jsMain/kotlin/dev/gitlive/firebase/firestore Expand file tree Collapse file tree 5 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -409,13 +409,18 @@ actual class SnapshotMetadata(val android: com.google.firebase.firestore.Snapsho
409409}
410410
411411actual class FieldPath private constructor(val android : com.google.firebase.firestore.FieldPath ) {
412+
413+ actual companion object {
414+ actual val documentId = FieldPath (com.google.firebase.firestore.FieldPath .documentId())
415+ }
416+
412417 actual constructor (vararg fieldNames: String ) : this (
413418 com.google.firebase.firestore.FieldPath .of(
414419 * fieldNames
415420 )
416421 )
417422
418- actual val documentId: FieldPath get() = FieldPath (com.google.firebase.firestore. FieldPath . documentId())
423+ actual val documentId: FieldPath get() = FieldPath . documentId
419424 actual val encoded: EncodedFieldPath = android
420425 override fun equals (other : Any? ): Boolean = other is FieldPath && android == other.android
421426 override fun hashCode (): Int = android.hashCode()
Original file line number Diff line number Diff line change @@ -544,6 +544,10 @@ expect class SnapshotMetadata {
544544}
545545
546546expect class FieldPath (vararg fieldNames : String ) {
547+ companion object {
548+ val documentId: FieldPath
549+ }
550+ @Deprecated(" Use companion object instead" , replaceWith = ReplaceWith (" FieldPath.documentId" ))
547551 val documentId: FieldPath
548552 val encoded: EncodedFieldPath
549553}
Original file line number Diff line number Diff line change @@ -658,7 +658,6 @@ class FirebaseFirestoreTest {
658658 assertEquals(setOf (DocumentWithTimestamp (futureTimestamp)), gtQueryResult)
659659 }
660660
661-
662661 @Test
663662 fun testGeoPointSerialization () = runTest {
664663 @Serializable
@@ -1017,6 +1016,16 @@ class FirebaseFirestoreTest {
10171016 andOrQuery.assertDocuments(FirestoreTest .serializer(), testOne)
10181017 }
10191018
1019+ @Test
1020+ fun testQueryByDocumentId () = runTest {
1021+ setupFirestoreData()
1022+
1023+ val fieldQuery = firestore
1024+ .collection(" testFirestoreQuerying" )
1025+ .where { FieldPath .documentId equalTo " one" }
1026+ fieldQuery.assertDocuments(FirestoreTest .serializer(), testOne)
1027+ }
1028+
10201029 private suspend fun setupFirestoreData (
10211030 documentOne : FirestoreTest = testOne,
10221031 documentTwo : FirestoreTest = testTwo,
Original file line number Diff line number Diff line change @@ -436,8 +436,11 @@ actual class SnapshotMetadata(val ios: FIRSnapshotMetadata) {
436436}
437437
438438actual class FieldPath private constructor(val ios : FIRFieldPath ) {
439+ actual companion object {
440+ actual val documentId = FieldPath (FIRFieldPath .documentID())
441+ }
439442 actual constructor (vararg fieldNames: String ) : this (FIRFieldPath (fieldNames.asList()))
440- actual val documentId: FieldPath get() = FieldPath ( FIRFieldPath .documentID())
443+ actual val documentId: FieldPath get() = FieldPath .documentId
441444 actual val encoded: EncodedFieldPath = ios
442445 override fun equals (other : Any? ): Boolean = other is FieldPath && ios == other.ios
443446 override fun hashCode (): Int = ios.hashCode()
Original file line number Diff line number Diff line change @@ -438,10 +438,14 @@ actual class SnapshotMetadata(val js: JsSnapshotMetadata) {
438438}
439439
440440actual class FieldPath private constructor(val js : JsFieldPath ) {
441+
442+ actual companion object {
443+ actual val documentId = FieldPath (JsFieldPath .documentId)
444+ }
441445 actual constructor (vararg fieldNames: String ) : this (dev.gitlive.firebase.firestore.rethrow {
442446 js(" Reflect" ).construct(JsFieldPath , fieldNames).unsafeCast<JsFieldPath >()
443447 })
444- actual val documentId: FieldPath get() = FieldPath ( JsFieldPath .documentId)
448+ actual val documentId: FieldPath get() = FieldPath .documentId
445449 actual val encoded: EncodedFieldPath = js
446450 override fun equals (other : Any? ): Boolean = other is FieldPath && js.isEqual(other.js)
447451 override fun hashCode (): Int = js.hashCode()
You can’t perform that action at this time.
0 commit comments