TableRequest
public protocol TableRequest
The protocol for all requests that feed from a database table
-
The name of the database table
Declaration
Swift
var databaseTableName: String { get }
-
Creates a request that allows you to define expressions that target a specific database table.
In the example below, the “team.avgScore < player.score” condition in the ON clause could be not achieved without table aliases.
struct Player: TableRecord { static let team = belongsTo(Team.self) } // SELECT player.*, team.* // JOIN team ON ... AND team.avgScore < player.score let playerAlias = TableAlias() let request = Player .all() .aliased(playerAlias) .including(required: Player.team.filter(Column("avgScore") < playerAlias[Column("score")])
Declaration
Swift
func aliased(_ alias: TableAlias) -> Self
-
matching(_:
Extension method) Creates a request with a full-text predicate added to the eventual set of already applied predicates.
// SELECT * FROM book WHERE book MATCH '...' var request = Book.all() request = request.matching(pattern)
If the search pattern is nil, the request does not match any database row.
Declaration
Swift
public func matching(_ pattern: FTS3Pattern?) -> Self
-
filter(key:
Extension method) Creates a request with the provided primary key predicate.
Declaration
Swift
public func filter<PrimaryKeyType>(key: PrimaryKeyType?) -> Self where PrimaryKeyType : DatabaseValueConvertible
-
filter(keys:
Extension method) Creates a request with the provided primary key predicate.
Declaration
Swift
public func filter<Sequence: Swift.Sequence>(keys: Sequence) -> Self where Sequence.Element: DatabaseValueConvertible
-
filter(key:
Extension method) Creates a request with the provided primary key predicate.
When executed, this request raises a fatal error if there is no unique index on the key columns.
Declaration
Swift
public func filter(key: [String : DatabaseValueConvertible?]?) -> Self
-
filter(keys:
Extension method) Creates a request with the provided primary key predicate.
When executed, this request raises a fatal error if there is no unique index on the key columns.
Declaration
Swift
public func filter(keys: [[String : DatabaseValueConvertible?]]) -> Self
-
orderByPrimaryKey()
Extension methodCreates a request ordered by primary key.
Declaration
Swift
public func orderByPrimaryKey() -> Self
-
groupByPrimaryKey()
Extension methodCreates a request grouped by primary key.
Declaration
Swift
public func groupByPrimaryKey() -> Self