iosMain.dev.gitlive.firebase.firestore.FieldValue.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of firebase-firestore Show documentation
Show all versions of firebase-firestore Show documentation
The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the Firebase Android SDK Kotlin Extensions but also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting iOS, Android or JS.
package dev.gitlive.firebase.firestore
import cocoapods.FirebaseFirestoreInternal.FIRFieldValue
import kotlinx.serialization.Serializable
/** A class representing a platform specific Firebase FieldValue. */
private typealias NativeFieldValue = FIRFieldValue
/** Represents a Firebase FieldValue. */
@Serializable(with = FieldValueSerializer::class)
public 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()
public actual companion object {
public actual val serverTimestamp: FieldValue get() = FieldValue(NativeFieldValue.fieldValueForServerTimestamp())
public actual val delete: FieldValue get() = FieldValue(NativeFieldValue.fieldValueForDelete())
public actual fun increment(value: Int): FieldValue = FieldValue(NativeFieldValue.fieldValueForIntegerIncrement(value.toLong()))
public actual fun arrayUnion(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.fieldValueForArrayUnion(elements.asList()))
public actual fun arrayRemove(vararg elements: Any): FieldValue = FieldValue(NativeFieldValue.fieldValueForArrayRemove(elements.asList()))
}
}