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
-
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
-
filter(key:)
Extension methodCreates a request with the provided primary key predicate.
Declaration
Swift
public func filter<PrimaryKeyType: DatabaseValueConvertible>(key: PrimaryKeyType?) -> Self
-
filter(keys:)
Extension methodCreates 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 methodCreates 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 methodCreates 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