FetchRequest
The protocol for all requests that fetch database rows, and tell how those rows should be interpreted.
struct Player: FetchableRecord { ... }
let request: some FetchRequest<Player> = ...
try request.fetchCursor(db) // Cursor of Player
try request.fetchAll(db)    // [Player]
try request.fetchSet(db)    // Set<Player>
try request.fetchOne(db)    // Player?
try request.fetchCount(db)  // Int
          - 
                  
                  
The type that tells how fetched database rows should be interpreted.
 - 
                  
                  
Returns a PreparedRequest that is ready to be executed.
 - 
                  
                  
Returns the number of rows fetched by the request.
 
- 
                  
fetchCursor(_:Extension method) A cursor over fetched values.
let request: some FetchRequest<String> = ... let strings = try request.fetchCursor(db) // Cursor of String while let string = try strings.next() { // String ... }If the database is modified during the cursor iteration, the remaining elements are undefined.
The cursor must be iterated in a protected dispatch queue.
Throws
A DatabaseError is thrown whenever an SQLite error occurs. - 
                  
fetchAll(_:Extension method) An array of fetched values.
let request: some FetchRequest<String> = ... let strings = try request.fetchAll(db) // [String]Throws
A DatabaseError is thrown whenever an SQLite error occurs. - 
                  
fetchOne(_:Extension method) The first fetched value.
The result is nil if the request returns no row, or if no value can be extracted from the first row.
let request: some FetchRequest<String> = ... let string = try request.fetchOne(db) // String?Throws
A DatabaseError is thrown whenever an SQLite error occurs. 
- 
                  
fetchSet(_:Extension method) A set of fetched values.
let request: some FetchRequest<String> = ... let strings = try request.fetchSet(db) // Set<String>Throws
A DatabaseError is thrown whenever an SQLite error occurs. 
- 
                  
databaseRegion(_:Extension method) Returns the database region that the request feeds from.
 
- 
                  
adapted(_:Extension method) Returns an adapted request.
 
View on GitHub
Install in Dash
        FetchRequest Protocol Reference