diff --git a/README.md b/README.md
index 05d26bffd..e9945537d 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ Asynchronous operations that return a single or no value are represented by susp
suspend fun signInWithCustomToken(token: String): AuthResult
```
-It is important to remember that unlike a callback based API, wating for suspending functions to complete is implicit and so if you don't want to wait for the result you can `launch` a new coroutine:
+It is important to remember that unlike a callback based API, waiting for suspending functions to complete is implicit and so if you don't want to wait for the result you can `launch` a new coroutine:
```kotlin
//TODO don't use GlobalScope
@@ -209,8 +209,6 @@ user.updateProfile(profileUpdates)
user.updateProfile(displayName = "Jane Q. User", photoURL = "https://example.com/jane-q-user/profile.jpg")
```
-
-
To improve readability and reduce boilerplate for functions such as the Cloud Firestore query operators are built with infix notation:
@@ -241,13 +239,18 @@ citiesRef.where {
}
```
-Similar methods exist for `update` methods in the Firestore module:
+Similar methods exist for `update`/`startAt`/`startAfter`/`endAt`/`endBefore` methods in the Firestore module:
```kotlin
documentRef.update {
"field" to "value"
"otherField".to(IntAsStringSerializer(), 1)
}
+
+query.orderBy("field", "otherField").startAt { // similar syntax for startAfter/endAt/endBefore
+ add("Value")
+ add(1, IntAsStringSerializer())
+}
```
diff --git a/firebase-firestore/api/android/firebase-firestore.api b/firebase-firestore/api/android/firebase-firestore.api
index 9cf847e6b..50a8e7fed 100644
--- a/firebase-firestore/api/android/firebase-firestore.api
+++ b/firebase-firestore/api/android/firebase-firestore.api
@@ -68,15 +68,15 @@ public final class dev/gitlive/firebase/firestore/DocumentReference {
public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/DocumentReference;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public fun toString ()Ljava/lang/String;
- public final fun update (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun updateEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
- public final fun updateFieldPaths (Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateFieldPaths ([Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
- public final fun updateFields (Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateFields (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateFields ([Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/gitlive/firebase/firestore/DocumentReference$Companion {
@@ -160,13 +160,6 @@ public final class dev/gitlive/firebase/firestore/FieldValue$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
-public final class dev/gitlive/firebase/firestore/FieldValueBuilder {
- public final fun addEncoded (Ljava/lang/Object;)V
- public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V
- public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1;
- public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V
-}
-
public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx/serialization/KSerializer {
public static final field INSTANCE Ldev/gitlive/firebase/firestore/FieldValueSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/FieldValue;
@@ -176,7 +169,14 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
}
-public final class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder {
+public final class dev/gitlive/firebase/firestore/FieldValuesDSL {
+ public final fun addEncoded (Ljava/lang/Object;)V
+ public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V
+ public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1;
+ public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V
+}
+
+public final class dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL {
public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1;
public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V
public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V
@@ -441,13 +441,13 @@ public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings
public class dev/gitlive/firebase/firestore/Query {
public static final field Companion Ldev/gitlive/firebase/firestore/Query$Companion;
public final fun endAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query;
- public final fun endAt (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
- public final fun endAt (Lkotlin/jvm/functions/Function1;[Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
public final fun endAt ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun endAt ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun endAtFieldValues (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
public final fun endBefore (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query;
- public final fun endBefore (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
- public final fun endBefore (Lkotlin/jvm/functions/Function1;[Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
public final fun endBefore ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun endBefore ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun endBeforeFieldValues (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow;
@@ -459,13 +459,13 @@ public class dev/gitlive/firebase/firestore/Query {
public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/Query;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public final fun startAfter (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query;
- public final fun startAfter (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
- public final fun startAfter (Lkotlin/jvm/functions/Function1;[Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
public final fun startAfter ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun startAfter ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun startAfterFieldValues (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
public final fun startAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query;
- public final fun startAt (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
- public final fun startAt (Lkotlin/jvm/functions/Function1;[Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
public final fun startAt ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun startAt ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun startAtFieldValues (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
public final fun where (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
}
@@ -581,16 +581,16 @@ public final class dev/gitlive/firebase/firestore/Transaction {
public fun toString ()Ljava/lang/String;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction;
- public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction;
public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction;
public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/Transaction;
- public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/Transaction;
- public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/Transaction;
+ public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
+ public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/Transaction;
+ public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
}
public final class dev/gitlive/firebase/firestore/Transaction$Companion {
@@ -719,15 +719,15 @@ public final class dev/gitlive/firebase/firestore/WriteBatch {
public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/WriteBatch;
public fun toString ()Ljava/lang/String;
- public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/WriteBatch;
public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/WriteBatch;
- public final fun updateField (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun updateField (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/WriteBatch;
- public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/WriteBatch;
+ public final fun updateField (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/WriteBatch;
+ public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
+ public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
}
public final class dev/gitlive/firebase/firestore/WriteBatch$Companion {
diff --git a/firebase-firestore/api/jvm/firebase-firestore.api b/firebase-firestore/api/jvm/firebase-firestore.api
index 6b5abda69..1deee3348 100644
--- a/firebase-firestore/api/jvm/firebase-firestore.api
+++ b/firebase-firestore/api/jvm/firebase-firestore.api
@@ -68,15 +68,15 @@ public final class dev/gitlive/firebase/firestore/DocumentReference {
public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/DocumentReference;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public fun toString ()Ljava/lang/String;
- public final fun update (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun update (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun updateEncoded (Ldev/gitlive/firebase/internal/EncodedObject;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
- public final fun updateFieldPaths (Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateFieldPaths ([Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
- public final fun updateFields (Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateFieldPaths ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateFields (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun updateFields ([Lkotlin/Pair;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateFields ([Lkotlin/Pair;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/gitlive/firebase/firestore/DocumentReference$Companion {
@@ -160,13 +160,6 @@ public final class dev/gitlive/firebase/firestore/FieldValue$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
-public final class dev/gitlive/firebase/firestore/FieldValueBuilder {
- public final fun addEncoded (Ljava/lang/Object;)V
- public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V
- public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1;
- public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V
-}
-
public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx/serialization/KSerializer {
public static final field INSTANCE Ldev/gitlive/firebase/firestore/FieldValueSerializer;
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/gitlive/firebase/firestore/FieldValue;
@@ -176,7 +169,14 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
}
-public final class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder {
+public final class dev/gitlive/firebase/firestore/FieldValuesDSL {
+ public final fun addEncoded (Ljava/lang/Object;)V
+ public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V
+ public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1;
+ public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V
+}
+
+public final class dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL {
public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1;
public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V
public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V
@@ -441,13 +441,13 @@ public final class dev/gitlive/firebase/firestore/MemoryGarbageCollectorSettings
public class dev/gitlive/firebase/firestore/Query {
public static final field Companion Ldev/gitlive/firebase/firestore/Query$Companion;
public final fun endAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query;
- public final fun endAt (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
- public final fun endAt (Lkotlin/jvm/functions/Function1;[Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
public final fun endAt ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun endAt ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun endAtFieldValues (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
public final fun endBefore (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query;
- public final fun endBefore (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
- public final fun endBefore (Lkotlin/jvm/functions/Function1;[Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
public final fun endBefore ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun endBefore ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun endBeforeFieldValues (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
public final fun get (Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun get$default (Ldev/gitlive/firebase/firestore/Query;Ldev/gitlive/firebase/firestore/Source;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final fun getSnapshots ()Lkotlinx/coroutines/flow/Flow;
@@ -459,13 +459,13 @@ public class dev/gitlive/firebase/firestore/Query {
public final fun snapshots (Z)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun snapshots$default (Ldev/gitlive/firebase/firestore/Query;ZILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public final fun startAfter (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query;
- public final fun startAfter (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
- public final fun startAfter (Lkotlin/jvm/functions/Function1;[Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
public final fun startAfter ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun startAfter ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun startAfterFieldValues (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
public final fun startAt (Ldev/gitlive/firebase/firestore/DocumentSnapshot;)Ldev/gitlive/firebase/firestore/Query;
- public final fun startAt (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
- public final fun startAt (Lkotlin/jvm/functions/Function1;[Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
public final fun startAt ([Ljava/lang/Object;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun startAt ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
+ public final fun startAtFieldValues (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
public final fun where (Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Query;
}
@@ -581,16 +581,16 @@ public final class dev/gitlive/firebase/firestore/Transaction {
public fun toString ()Ljava/lang/String;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction;
- public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/Transaction;
public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction;
public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/Transaction;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/Transaction;
- public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/Transaction;
- public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/Transaction;
+ public final fun updateFieldPaths (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
+ public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/Transaction;
+ public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/Transaction;
}
public final class dev/gitlive/firebase/firestore/Transaction$Companion {
@@ -719,15 +719,15 @@ public final class dev/gitlive/firebase/firestore/WriteBatch {
public static synthetic fun set$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;[Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun setEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;Ldev/gitlive/firebase/firestore/internal/SetOptions;)Ldev/gitlive/firebase/firestore/WriteBatch;
public fun toString ()Ljava/lang/String;
- public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun update (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Z)Ldev/gitlive/firebase/firestore/WriteBatch;
public static synthetic fun update$default (Ldev/gitlive/firebase/firestore/WriteBatch;Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun updateEncoded (Ldev/gitlive/firebase/firestore/DocumentReference;Ldev/gitlive/firebase/internal/EncodedObject;)Ldev/gitlive/firebase/firestore/WriteBatch;
- public final fun updateField (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun updateField (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/WriteBatch;
- public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/WriteBatch;
+ public final fun updateField (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;)Ldev/gitlive/firebase/firestore/WriteBatch;
+ public final fun updateFieldPath (Ldev/gitlive/firebase/firestore/DocumentReference;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
+ public final fun updateFields (Ldev/gitlive/firebase/firestore/DocumentReference;Lkotlin/jvm/functions/Function1;)Ldev/gitlive/firebase/firestore/WriteBatch;
}
public final class dev/gitlive/firebase/firestore/WriteBatch$Companion {
diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt
deleted file mode 100644
index 53d5a0d13..000000000
--- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package dev.gitlive.firebase.firestore
-
-import dev.gitlive.firebase.EncodeSettings
-import kotlinx.serialization.SerializationStrategy
-
-public class FieldValueBuilder internal constructor() {
-
- internal val fieldValues: MutableList = mutableListOf()
- public var buildSettings: EncodeSettings.Builder.() -> Unit = {
- encodeDefaults = true
- }
-
- public inline fun add(value: T) {
- addEncoded(encode(value, buildSettings)!!)
- }
-
- public fun addWithStrategy(strategy: SerializationStrategy, value: T) {
- addEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!)
- }
-
- @PublishedApi
- internal fun addEncoded(encodedValue: Any) {
- fieldValues += encodedValue
- }
-}
diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValuesDSL.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValuesDSL.kt
new file mode 100644
index 000000000..f0d851a42
--- /dev/null
+++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValuesDSL.kt
@@ -0,0 +1,53 @@
+package dev.gitlive.firebase.firestore
+
+import dev.gitlive.firebase.EncodeSettings
+import kotlinx.serialization.SerializationStrategy
+
+/**
+ * A builder for generating the field values of a [Query].
+ * The order of the field values must match the order by clauses of the [Query]
+ */
+public class FieldValuesDSL internal constructor() {
+
+ internal val fieldValues: MutableList = mutableListOf()
+
+ /**
+ * The [EncodeSettings.Builder] to apply to the next field values added.
+ * Updating this value will only influence the encoding of field values not yet added to the update.
+ * This allows for custom encoding per value, e.g.
+ *
+ * ```
+ * buildSettings = { encodeDefaults = true }
+ * add(ClassWithDefaults())
+ * buildSettings = { encodeDefaults = false }
+ * add(ClassWithDefaults())
+ * ```
+ */
+ public var buildSettings: EncodeSettings.Builder.() -> Unit = {
+ encodeDefaults = true
+ }
+
+ /**
+ * Adds a field value to the [Query]
+ * @param T the type of the value to add
+ * @param value the value [T] to add
+ */
+ public inline fun add(value: T) {
+ addEncoded(encode(value, buildSettings)!!)
+ }
+
+ /**
+ * Adds a field value to the [Query]
+ * @param T the type of the value to add
+ * @param strategy the [SerializationStrategy] to apply to the value
+ * @param value the value [T] to add
+ */
+ public fun addWithStrategy(strategy: SerializationStrategy, value: T) {
+ addEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings)!!)
+ }
+
+ @PublishedApi
+ internal fun addEncoded(encodedValue: Any) {
+ fieldValues += encodedValue
+ }
+}
diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt
deleted file mode 100644
index aba64b228..000000000
--- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-package dev.gitlive.firebase.firestore
-
-import dev.gitlive.firebase.EncodeSettings
-import dev.gitlive.firebase.firestore.internal.FieldAndValue
-import kotlinx.serialization.SerializationStrategy
-
-public class FieldsAndValuesBuilder internal constructor() {
-
- internal val fieldAndValues: MutableList = mutableListOf()
- public var buildSettings: EncodeSettings.Builder.() -> Unit = {
- encodeDefaults = true
- }
-
- public inline infix fun String.to(value: T) {
- toEncoded(encode(value, buildSettings))
- }
-
- public inline infix fun FieldPath.to(value: T) {
- toEncoded(encode(value, buildSettings))
- }
-
- public fun String.to(strategy: SerializationStrategy, value: T) {
- toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings))
- }
-
- public fun FieldPath.to(strategy: SerializationStrategy, value: T) {
- toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings))
- }
-
- @PublishedApi
- internal fun String.toEncoded(encodedValue: Any?) {
- fieldAndValues += FieldAndValue.WithStringField(this, encodedValue)
- }
-
- @PublishedApi
- internal fun FieldPath.toEncoded(encodedValue: Any?) {
- fieldAndValues += FieldAndValue.WithFieldPath(this, encodedValue)
- }
-}
diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL.kt
new file mode 100644
index 000000000..7fca11765
--- /dev/null
+++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesUpdateDSL.kt
@@ -0,0 +1,89 @@
+package dev.gitlive.firebase.firestore
+
+import dev.gitlive.firebase.EncodeSettings
+import dev.gitlive.firebase.firestore.internal.FieldAndValue
+import kotlinx.serialization.SerializationStrategy
+
+/**
+ * A builder for generating a collection of updates to a document.
+ * Updates can be applied to either a String field or to a [FieldPath].
+ * Within this builder custom serialization can be applied to the update.
+ *
+ * ```
+ * val update: FieldsAndValuesUpdateBuilder.() -> Unit = {
+ * buildSettings = { encodeDefaults = false }
+ *
+ * "path" to 1
+ * FieldPath("subpath", "field") to "value"
+ * "otherPath".to(strategy, value)
+ * }
+ * ```
+ */
+public class FieldsAndValuesUpdateDSL internal constructor() {
+
+ internal val fieldAndValues: MutableList = mutableListOf()
+
+ /**
+ * The [EncodeSettings.Builder] to apply to the next values added to this update.
+ * Updating this value will only influence the encoding of values not yet added to the update.
+ * This allows for custom encoding per update, e.g.
+ *
+ * ```
+ * buildSettings = { encodeDefaults = true }
+ * "path" to ClassWithDefaults()
+ * buildSettings = { encodeDefaults = false }
+ * "otherPath" to ClassWithDefaults()
+ * ```
+ */
+ public var buildSettings: EncodeSettings.Builder.() -> Unit = {
+ encodeDefaults = true
+ }
+
+ /**
+ * Updates the field represented by a String to a given value
+ * @param T the type of the value
+ * @param value the value [T] to update to
+ */
+ public inline infix fun String.to(value: T) {
+ toEncoded(encode(value, buildSettings))
+ }
+
+ /**
+ * Updates a [FieldPath] to a given value
+ * @param T the type of the value
+ * @param value the value [T] to update to
+ */
+ public inline infix fun FieldPath.to(value: T) {
+ toEncoded(encode(value, buildSettings))
+ }
+
+ /**
+ * Updates the field represented by a String to a given value
+ * @param T the type of the value
+ * @param strategy the [SerializationStrategy] to apply to the value
+ * @param value the value [T] to update to
+ */
+ public fun String.to(strategy: SerializationStrategy, value: T) {
+ toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings))
+ }
+
+ /**
+ * Updates a [FieldPath] to a given value
+ * @param T the type of the value
+ * @param strategy the [SerializationStrategy] to apply to the value
+ * @param value the value [T] to update to
+ */
+ public fun FieldPath.to(strategy: SerializationStrategy, value: T) {
+ toEncoded(dev.gitlive.firebase.internal.encode(strategy, value, buildSettings))
+ }
+
+ @PublishedApi
+ internal fun String.toEncoded(encodedValue: Any?) {
+ fieldAndValues += FieldAndValue.WithStringField(this, encodedValue)
+ }
+
+ @PublishedApi
+ internal fun FieldPath.toEncoded(encodedValue: Any?) {
+ fieldAndValues += FieldAndValue.WithFieldPath(this, encodedValue)
+ }
+}
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 c87f4194c..c5a9b493e 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
@@ -193,11 +193,11 @@ public data class Transaction internal constructor(internal val nativeWrapper: N
@JvmName("updateFields")
public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair): Transaction =
- update(documentRef, {}, *fieldsAndValues)
+ update(documentRef, *fieldsAndValues) {}
@JvmName("updateFields")
- public fun update(documentRef: DocumentReference, buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldsAndValues: Pair): Transaction =
- update(
+ public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit): Transaction =
+ updateFields(
documentRef,
) {
this.buildSettings = buildSettings
@@ -208,11 +208,11 @@ public data class Transaction internal constructor(internal val nativeWrapper: N
@JvmName("updateFieldPaths")
public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair): Transaction =
- update(documentRef, {}, *fieldsAndValues)
+ update(documentRef, *fieldsAndValues) {}
@JvmName("updateFieldPaths")
- public fun update(documentRef: DocumentReference, buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldsAndValues: Pair): Transaction =
- update(
+ public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit): Transaction =
+ updateFields(
documentRef,
) {
this.buildSettings = buildSettings
@@ -221,10 +221,15 @@ public data class Transaction internal constructor(internal val nativeWrapper: N
}
}
- public fun update(
+ /**
+ * Updates Fields/[FieldPath] of a [DocumentReference] using a [FieldsAndValuesUpdateDSL].
+ * @param documentRef the [DocumentReference] to update
+ * @param fieldsAndValuesUpdateDSL closure for configuring the [FieldsAndValuesUpdateDSL]
+ */
+ public fun updateFields(
documentRef: DocumentReference,
- fieldsAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit,
- ): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues))
+ fieldsAndValuesUpdateDSL: FieldsAndValuesUpdateDSL.() -> Unit,
+ ): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, FieldsAndValuesUpdateDSL().apply(fieldsAndValuesUpdateDSL).fieldAndValues))
@PublishedApi
internal fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, encodedData))
@@ -254,52 +259,76 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue
public fun orderBy(field: FieldPath, direction: Direction = Direction.ASCENDING): Query = Query(nativeQuery.orderBy(field.encoded, direction))
public fun startAfter(document: DocumentSnapshot): Query = Query(nativeQuery.startAfter(document.native))
- public fun startAfter(vararg fieldValues: Any?): Query = startAfter({}, *fieldValues)
- public fun startAfter(buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldValues: Any?): Query =
- startAfter {
+ public fun startAfter(vararg fieldValues: Any?): Query = startAfter(*fieldValues) {}
+ public fun startAfter(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit): Query =
+ startAfterFieldValues {
this.buildSettings = buildSettings
fieldValues.forEach {
add(it)
}
}
- public fun startAfter(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAfter(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray()))
+ /**
+ * Creates and returns a new [Query] that starts after the provided fields relative to the order of the query.
+ * The field values are configured using a [FieldValuesDSL].
+ * The order of the field values must match the order of the [orderBy] clauses of the query
+ * @param builder closure for configuring the [FieldValuesDSL]
+ */
+ public fun startAfterFieldValues(builder: FieldValuesDSL.() -> Unit): Query = Query(nativeQuery.startAfter(*FieldValuesDSL().apply(builder).fieldValues.toTypedArray()))
public fun startAt(document: DocumentSnapshot): Query = Query(nativeQuery.startAt(document.native))
- public fun startAt(vararg fieldValues: Any?): Query = startAt({}, *fieldValues)
- public fun startAt(buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldValues: Any?): Query =
- startAt {
+ public fun startAt(vararg fieldValues: Any?): Query = startAt(*fieldValues) {}
+ public fun startAt(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit): Query =
+ startAtFieldValues {
this.buildSettings = buildSettings
fieldValues.forEach {
add(it)
}
}
- public fun startAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAt(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray()))
+ /**
+ * Creates and returns a new [Query] that starts at the provided fields relative to the order of the query.
+ * The field values are configured using a [FieldValuesDSL].
+ * The order of the field values must match the order of the [orderBy] clauses of the query
+ * @param builder closure for configuring the [FieldValuesDSL]
+ */
+ public fun startAtFieldValues(builder: FieldValuesDSL.() -> Unit): Query = Query(nativeQuery.startAt(*FieldValuesDSL().apply(builder).fieldValues.toTypedArray()))
public fun endBefore(document: DocumentSnapshot): Query = Query(nativeQuery.endBefore(document.native))
- public fun endBefore(vararg fieldValues: Any?): Query = endBefore({}, *fieldValues)
- public fun endBefore(buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldValues: Any?): Query =
- endBefore {
+ public fun endBefore(vararg fieldValues: Any?): Query = endBefore(*fieldValues) {}
+ public fun endBefore(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit): Query =
+ endBeforeFieldValues {
this.buildSettings = buildSettings
fieldValues.forEach {
add(it)
}
}
- public fun endBefore(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endBefore(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray()))
+ /**
+ * Creates and returns a new [Query] that ends before the provided fields relative to the order of the query.
+ * The field values are configured using a [FieldValuesDSL].
+ * The order of the field values must match the order of the [orderBy] clauses of the query
+ * @param builder closure for configuring the [FieldValuesDSL]
+ */
+ public fun endBeforeFieldValues(builder: FieldValuesDSL.() -> Unit): Query = Query(nativeQuery.endBefore(*FieldValuesDSL().apply(builder).fieldValues.toTypedArray()))
public fun endAt(document: DocumentSnapshot): Query = Query(nativeQuery.endAt(document.native))
- public fun endAt(vararg fieldValues: Any?): Query = endAt({}, *fieldValues)
- public fun endAt(buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldValues: Any?): Query =
- endAt {
+ public fun endAt(vararg fieldValues: Any?): Query = endAt(*fieldValues) {}
+ public fun endAt(vararg fieldValues: Any?, buildSettings: EncodeSettings.Builder.() -> Unit): Query =
+ endAtFieldValues {
this.buildSettings = buildSettings
fieldValues.forEach {
add(it)
}
}
- public fun endAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endAt(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray()))
+ /**
+ * Creates and returns a new [Query] that ends at the provided fields relative to the order of the query.
+ * The field values are configured using a [FieldValuesDSL].
+ * The order of the field values must match the order of the [orderBy] clauses of the query
+ * @param builder closure for configuring the [FieldValuesDSL]
+ */
+ public fun endAtFieldValues(builder: FieldValuesDSL.() -> Unit): Query = Query(nativeQuery.endAt(*FieldValuesDSL().apply(builder).fieldValues.toTypedArray()))
}
@Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { field equalTo equalTo }", "dev.gitlive.firebase.firestore"))
@@ -427,11 +456,11 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na
@JvmName("updateField")
public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair): WriteBatch =
- update(documentRef, {}, *fieldsAndValues)
+ update(documentRef, *fieldsAndValues) {}
@JvmName("updateField")
- public fun update(documentRef: DocumentReference, buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldsAndValues: Pair): WriteBatch =
- update(
+ public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit): WriteBatch =
+ updateFields(
documentRef,
) {
this.buildSettings = buildSettings
@@ -442,11 +471,11 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na
@JvmName("updateFieldPath")
public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair): WriteBatch =
- update(documentRef, {}, *fieldsAndValues)
+ update(documentRef, *fieldsAndValues) {}
@JvmName("updateFieldPath")
- public fun update(documentRef: DocumentReference, buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldsAndValues: Pair): WriteBatch =
- update(
+ public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit): WriteBatch =
+ updateFields(
documentRef,
) {
this.buildSettings = buildSettings
@@ -455,13 +484,18 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na
}
}
- public fun update(
+ /**
+ * Updates Fields/[FieldPath] of a [DocumentReference] using a [FieldsAndValuesUpdateDSL].
+ * @param documentRef the [DocumentReference] to update
+ * @param fieldsAndValuesUpdateDSL closure for configuring the [FieldsAndValuesUpdateDSL]
+ */
+ public fun updateFields(
documentRef: DocumentReference,
- fieldAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit,
+ fieldsAndValuesUpdateDSL: FieldsAndValuesUpdateDSL.() -> Unit,
): WriteBatch = WriteBatch(
nativeWrapper.updateEncoded(
documentRef,
- FieldsAndValuesBuilder().apply(fieldAndValuesBuilder).fieldAndValues,
+ FieldsAndValuesUpdateDSL().apply(fieldsAndValuesUpdateDSL).fieldAndValues,
),
)
@@ -606,11 +640,11 @@ public data class DocumentReference internal constructor(internal val native: Na
@JvmName("updateFields")
public suspend fun update(vararg fieldsAndValues: Pair): Unit =
- update({}, *fieldsAndValues)
+ update(*fieldsAndValues) {}
@JvmName("updateFields")
- public suspend fun update(buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldsAndValues: Pair): Unit =
- update {
+ public suspend fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit): Unit =
+ updateFields {
this.buildSettings = buildSettings
fieldsAndValues.forEach { (field, value) ->
field to value
@@ -619,21 +653,25 @@ public data class DocumentReference internal constructor(internal val native: Na
@JvmName("updateFieldPaths")
public suspend fun update(vararg fieldsAndValues: Pair): Unit =
- update({}, *fieldsAndValues)
+ update(*fieldsAndValues) {}
@JvmName("updateFieldPaths")
- public suspend fun update(buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldsAndValues: Pair): Unit =
- update {
+ public suspend fun update(vararg fieldsAndValues: Pair, buildSettings: EncodeSettings.Builder.() -> Unit): Unit =
+ updateFields {
this.buildSettings = buildSettings
fieldsAndValues.forEach { (fieldPath, value) ->
fieldPath to value
}
}
- public suspend fun update(
- fieldsAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit,
+ /**
+ * Updates Fields/[FieldPath] using a [FieldsAndValuesUpdateDSL].
+ * @param fieldsAndValuesUpdateDSL closure for configuring the [FieldsAndValuesUpdateDSL]
+ */
+ public suspend fun updateFields(
+ fieldsAndValuesUpdateDSL: FieldsAndValuesUpdateDSL.() -> Unit,
) {
- native.updateEncoded(FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues)
+ native.updateEncoded(FieldsAndValuesUpdateDSL().apply(fieldsAndValuesUpdateDSL).fieldAndValues)
}
public suspend fun delete() {
diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/DocumentReferenceTest.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/DocumentReferenceTest.kt
index d58024788..1862dba40 100644
--- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/DocumentReferenceTest.kt
+++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/DocumentReferenceTest.kt
@@ -205,7 +205,7 @@ class DocumentReferenceTest : BaseFirebaseFirestoreTest() {
assertEquals(NestedObject("nested"), dataBefore.nested)
assertEquals(600.milliseconds, dataBefore.duration)
- doc.update {
+ doc.updateFields {
FirestoreTest::count.name to 5
FieldPath(FirestoreTest::optional.name) to "notNull"
FirestoreTest::nested.name.to(
@@ -367,7 +367,7 @@ class DocumentReferenceTest : BaseFirebaseFirestoreTest() {
// update data
val updatedData = DataWithDocumentReference(documentRef2)
- document.update {
+ document.updateFields {
FieldPath(DataWithDocumentReference::documentReference.name).to(
DocumentReferenceSerializer,
updatedData.documentReference,
diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/QueryTest.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/QueryTest.kt
index 665044bda..c95700acd 100644
--- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/QueryTest.kt
+++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/QueryTest.kt
@@ -446,7 +446,7 @@ open class QueryTest : BaseFirebaseFirestoreTest() {
val encodedQuery = collection
.orderBy(FirestoreTest::nested.name, Direction.ASCENDING)
- val encodedSecondPage = encodedQuery.startAfter {
+ val encodedSecondPage = encodedQuery.startAfterFieldValues {
addWithStrategy(NestedObject.serializer(), NestedObject("eee"))
}
encodedSecondPage.assertDocuments(FirestoreTest.serializer(), testThree)
@@ -462,7 +462,7 @@ open class QueryTest : BaseFirebaseFirestoreTest() {
.orderBy(FieldPath(FirestoreTest::time.name), Direction.ASCENDING)
.orderBy(FirestoreTest::nested.name, Direction.ASCENDING)
- val encodedMultipleSecondPage = encodedMultipleQuery.startAfter {
+ val encodedMultipleSecondPage = encodedMultipleQuery.startAfterFieldValues {
add(0.0)
addWithStrategy(NestedObject.serializer(), NestedObject("ddd"))
}
@@ -495,7 +495,7 @@ open class QueryTest : BaseFirebaseFirestoreTest() {
val encodedQuery = collection
.orderBy(FirestoreTest::nested.name, Direction.ASCENDING)
- val encodedSecondPage = encodedQuery.startAt {
+ val encodedSecondPage = encodedQuery.startAtFieldValues {
addWithStrategy(NestedObject.serializer(), NestedObject("eee"))
}
encodedSecondPage.assertDocuments(FirestoreTest.serializer(), testTwo, testThree)
@@ -511,7 +511,7 @@ open class QueryTest : BaseFirebaseFirestoreTest() {
.orderBy(FieldPath(FirestoreTest::time.name), Direction.ASCENDING)
.orderBy(FirestoreTest::nested.name, Direction.ASCENDING)
- val encodedMultipleSecondPage = encodedMultipleQuery.startAt {
+ val encodedMultipleSecondPage = encodedMultipleQuery.startAtFieldValues {
add(0.0)
addWithStrategy(NestedObject.serializer(), NestedObject("eee"))
}
@@ -544,7 +544,7 @@ open class QueryTest : BaseFirebaseFirestoreTest() {
val encodedQuery = collection
.orderBy(FirestoreTest::nested.name, Direction.ASCENDING)
- val encodedSecondPage = encodedQuery.endBefore {
+ val encodedSecondPage = encodedQuery.endBeforeFieldValues {
addWithStrategy(NestedObject.serializer(), NestedObject("eee"))
}
encodedSecondPage.assertDocuments(FirestoreTest.serializer(), testOne)
@@ -560,7 +560,7 @@ open class QueryTest : BaseFirebaseFirestoreTest() {
.orderBy(FieldPath(FirestoreTest::time.name), Direction.ASCENDING)
.orderBy(FirestoreTest::nested.name, Direction.ASCENDING)
- val encodedMultipleSecondPage = encodedMultipleQuery.endBefore {
+ val encodedMultipleSecondPage = encodedMultipleQuery.endBeforeFieldValues {
add(0.0)
addWithStrategy(NestedObject.serializer(), NestedObject("eee"))
}
@@ -593,7 +593,7 @@ open class QueryTest : BaseFirebaseFirestoreTest() {
val encodedQuery = collection
.orderBy(FirestoreTest::nested.name, Direction.ASCENDING)
- val encodedSecondPage = encodedQuery.endAt {
+ val encodedSecondPage = encodedQuery.endAtFieldValues {
addWithStrategy(NestedObject.serializer(), NestedObject("eee"))
}
encodedSecondPage.assertDocuments(FirestoreTest.serializer(), testOne, testTwo)
@@ -609,7 +609,7 @@ open class QueryTest : BaseFirebaseFirestoreTest() {
.orderBy(FieldPath(FirestoreTest::time.name), Direction.ASCENDING)
.orderBy(FirestoreTest::nested.name, Direction.ASCENDING)
- val encodedMultipleSecondPage = encodedMultipleQuery.endAt {
+ val encodedMultipleSecondPage = encodedMultipleQuery.endAtFieldValues {
add(0.0)
addWithStrategy(NestedObject.serializer(), NestedObject("ddd"))
}
diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TransactionTest.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TransactionTest.kt
index 5a68d53a8..03684e3d6 100644
--- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TransactionTest.kt
+++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TransactionTest.kt
@@ -25,7 +25,7 @@ class TransactionTest : BaseFirebaseFirestoreTest() {
val count = get(document).data(FirestoreTest.serializer()).count
if (count < 1) {
- update(document) {
+ updateFields(document) {
FirestoreTest::prop1.name to "newProperty"
FieldPath(FirestoreTest::count.name) to 5
FirestoreTest::duration.name.to(DurationAsIntSerializer(), 100.milliseconds)