Request
public protocol Request
                The protocol for all types that define a way to fetch database rows.
Requests can feed the fetching methods of any fetchable type (Row, value, record):
let request: Request = ...
try Row.fetchCursor(db, request) // RowCursor
try String.fetchAll(db, request) // [String]
try Player.fetchOne(db, request) // Player?
          - 
                  
                  
A tuple that contains a prepared statement that is ready to be executed, and an eventual row adapter.
Declaration
Swift
func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) - 
                  
fetchCount(_:)Default implementationThe number of rows fetched by the request.
Default implementation builds a naive SQL query based on the statement returned by the
preparemethod:SELECT COUNT(*) FROM (...).Adopting types can refine this countRequest method and return more efficient SQL.
Default Implementation
The number of rows fetched by the request.
This default implementation builds a naive SQL query based on the statement returned by the
preparemethod:SELECT COUNT(*) FROM (...).Declaration
Swift
func fetchCount(_ db: Database) throws -> IntParameters
dbA database connection.
 
- 
                  
asSQLRequest(_:cached:)Extension methodReturns an equivalent SQLRequest.
Declaration
Swift
public func asSQLRequest(_ db: Database, cached: Bool = false) throws -> SQLRequestParameters
dbA database connection.
cachedDefaults to false. If true, the request reuses a cached prepared statement.
Return Value
An SQLRequest
 
- 
                  
asRequest(of:)Extension methodReturns a request bound to type T.
The returned request can fetch if the type T is fetchable (Row, value, record).
// Int? let maxScore = Player .select(max(scoreColumn)) .asRequest(of: Int.self) // <-- .fetchOne(db)Declaration
Swift
public func asRequest<T>(of type: T.Type) -> AnyTypedRequest<T>Parameters
typeThe fetched type T
Return Value
A typed request bound to type T.
 - 
                  
adapted(_:)Extension methodReturns an adapted request.
Declaration
Swift
public func adapted(_ adapter: @escaping (Database) throws -> RowAdapter) -> AdaptedRequest<Self> 
View on GitHub
Install in Dash
        Request Protocol Reference