Skip to content

Commit

Permalink
Expanded documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Daeda88 committed Oct 21, 2024
1 parent 0da0fd6 commit 6d72b0d
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,44 @@ In combination with a `SerialName` specified for the child class, you have full
}
```

<h4>Serialization of Updates</h4>
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)
}
```

<h3><a href="https://kotlinlang.org/docs/reference/functions.html#default-arguments">Default arguments</a></h3>

To reduce boilerplate, default arguments are used in the places where the Firebase Android SDK employs the builder pattern:
Expand Down Expand Up @@ -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())
}
```

<h3><a href="https://kotlinlang.org/docs/reference/operator-overloading.html">Operator overloading</a></h3>

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

0 comments on commit 6d72b0d

Please sign in to comment.