-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
166 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
firebase-firestore/src/jvmMain/kotlin/dev/gitlive/firebase/firestore/FieldValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package dev.gitlive.firebase.firestore | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
/** Represents a platform specific Firebase FieldValue. */ | ||
typealias NativeFieldValue = com.google.firebase.firestore.FieldValue | ||
|
||
/** Represents a Firebase FieldValue. */ | ||
@Serializable(with = FieldValueSerializer::class) | ||
actual class FieldValue internal actual constructor(internal actual val nativeValue: Any) { | ||
init { | ||
require(nativeValue is NativeFieldValue) | ||
} | ||
override fun equals(other: Any?): Boolean = | ||
this === other || other is FieldValue && nativeValue == other.nativeValue | ||
override fun hashCode(): Int = nativeValue.hashCode() | ||
override fun toString(): String = nativeValue.toString() | ||
|
||
actual companion object { | ||
actual val serverTimestamp: FieldValue get() = FieldValue(NativeFieldValue.serverTimestamp()) | ||
actual val delete: FieldValue get() = FieldValue(NativeFieldValue.delete()) | ||
actual fun increment(value: Int): FieldValue = FieldValue(NativeFieldValue.increment(value.toDouble())) | ||
actual fun arrayUnion(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.arrayUnion(*elements)) | ||
actual fun arrayRemove(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.arrayRemove(*elements)) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
firebase-firestore/src/jvmMain/kotlin/dev/gitlive/firebase/firestore/_encoders.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dev.gitlive.firebase.firestore | ||
|
||
@PublishedApi | ||
internal actual fun isSpecialValue(value: Any) = when(value) { | ||
is NativeFieldValue, | ||
is NativeGeoPoint, | ||
is NativeTimestamp, | ||
is NativeDocumentReference -> true | ||
else -> false | ||
} |
Oops, something went wrong.