mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Document the row comparison technique
This commit is contained in:
1 parent
e68bd077ee
commit
3a11d94bee
1 file changed
+10
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user