Document the row comparison technique

This commit is contained in:
Gwendal Roué committed 2020-03-25 22:07:12 +01:00
1 parent e68bd077ee
commit 3a11d94bee
1 file changed
+10
+10
View File
@@ -5672,6 +5672,16 @@ let observation = ValueObservation
.removeDuplicates()
```
When the observed values do not adopt Equatable, you can observe raw database values such as [Row](#row-queries) or [DatabaseValue](#databasevalue) before converting them to the desired type. For example, the previous observation can be rewritten as below:
```swift
// An observation of distinct Player?
let request = Player.filter(key: 42)
let observation = ValueObservation
.tracking { db in try Row.fetchOne(db, request) }
.removeDuplicates() // Row adopts Equatable
.map { row in row.map(Player.init(row:) }
```
#### ValueObservation.combine