Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/StructuredQueriesCore/TableAlias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ extension Table {
/// // ON "users"."referrerID" = "referrers"."id"
/// ```
///
/// Table aliases are representable in selections by providing the type to the `@Columns` macro:
///
/// ```swift
/// @Selection
/// struct UserWithReferrer {
/// let user: User
/// @Columns(as: TableAlias<User, Referrer>.self)
/// let referrer: User
/// }
///
/// let usersWithReferrers = User
/// .join(User.as(Referrer.self).all) { $0.referrerID == $1.id }
/// .select { UserWithReferrer.Columns(user: $0, referrer: $1) }
/// ```
///
/// - Parameter aliasName: An alias name for this table.
/// - Returns: A table alias of this table type.
public static func `as`<Name: AliasName>(_ aliasName: Name.Type) -> TableAlias<Self, Name>.Type {
Expand Down
Loading