Skip to content

Commit 6d72b0d

Browse files
committed
Expanded documentation
1 parent 0da0fd6 commit 6d72b0d

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

README.md

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,44 @@ In combination with a `SerialName` specified for the child class, you have full
185185
}
186186
```
187187

188+
<h4>Serialization of Updates</h4>
189+
Firestore contains update methods that allow for multiple fields to be updated at the same time.
190+
This sdk offers special update methods that allow for applying custom serialization to each individual field though an update builder.
191+
Where an `update` method exists, an `updateFields` method will also be available. In this, each value can have its serializer customized:
192+
193+
```kotlin
194+
documentRef.updateFields {
195+
"field" to "value"
196+
// Set the value of otherField to "1" using a custom Serializer
197+
"otherField".to(IntAsStringSerializer(), 1)
198+
199+
// Overwrite build settings. All fields added after this will have these build settings applied
200+
buildSettings = {
201+
encodeDefaults = true
202+
serializersModule = module
203+
}
204+
"city" to abstractCity
205+
}
206+
```
207+
208+
Similarly, the `Query` methods `startAt`/`startAfter`/`endAt`/`endBefore` have an alternative method in `startAtFieldValues`/`startAfterFieldValues`/`endAtFieldValues`/`endBeforeFieldValues`
209+
210+
```kotlin
211+
query.orderBy("field", "otherField", "city").startAtFieldValues { // similar syntax for startAfter/endAt/endBefore
212+
add("Value")
213+
214+
// Starts at "1" for the otherField value
215+
add(1, IntAsStringSerializer())
216+
217+
// Overwrite build settings. All field values added after this will have these build settings applied
218+
buildSettings = {
219+
encodeDefaults = true
220+
serializersModule = module
221+
}
222+
add(abstractCity)
223+
}
224+
```
225+
188226
<h3><a href="https://kotlinlang.org/docs/reference/functions.html#default-arguments">Default arguments</a></h3>
189227

190228
To reduce boilerplate, default arguments are used in the places where the Firebase Android SDK employs the builder pattern:
@@ -239,20 +277,6 @@ citiesRef.where {
239277
}
240278
```
241279

242-
Similar methods exist for `update`/`startAt`/`startAfter`/`endAt`/`endBefore` methods in the Firestore module:
243-
244-
```kotlin
245-
documentRef.update {
246-
"field" to "value"
247-
"otherField".to(IntAsStringSerializer(), 1)
248-
}
249-
250-
query.orderBy("field", "otherField").startAt { // similar syntax for startAfter/endAt/endBefore
251-
add("Value")
252-
add(1, IntAsStringSerializer())
253-
}
254-
```
255-
256280
<h3><a href="https://kotlinlang.org/docs/reference/operator-overloading.html">Operator overloading</a></h3>
257281

258282
In cases where it makes sense, such as Firebase Functions HTTPS Callable, operator overloading is used:

0 commit comments

Comments
 (0)