diff --git a/README.md b/README.md index e9945537d..76880b242 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,44 @@ In combination with a `SerialName` specified for the child class, you have full } ``` +

Serialization of Updates

+Firestore contains update methods that allow for multiple fields to be updated at the same time. +This sdk offers special update methods that allow for applying custom serialization to each individual field though an update builder. +Where an `update` method exists, an `updateFields` method will also be available. In this, each value can have its serializer customized: + +```kotlin +documentRef.updateFields { + "field" to "value" + // Set the value of otherField to "1" using a custom Serializer + "otherField".to(IntAsStringSerializer(), 1) + + // Overwrite build settings. All fields added after this will have these build settings applied + buildSettings = { + encodeDefaults = true + serializersModule = module + } + "city" to abstractCity +} +``` + +Similarly, the `Query` methods `startAt`/`startAfter`/`endAt`/`endBefore` have an alternative method in `startAtFieldValues`/`startAfterFieldValues`/`endAtFieldValues`/`endBeforeFieldValues` + +```kotlin +query.orderBy("field", "otherField", "city").startAtFieldValues { // similar syntax for startAfter/endAt/endBefore + add("Value") + + // Starts at "1" for the otherField value + add(1, IntAsStringSerializer()) + + // Overwrite build settings. All field values added after this will have these build settings applied + buildSettings = { + encodeDefaults = true + serializersModule = module + } + add(abstractCity) +} +``` +

Default arguments

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 { } ``` -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()) -} -``` -

Operator overloading

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