Skip to content

Instance Method

select(_:)

Specify a SELECT query to generate rows to insert.
@discardableResult func select(_ closure: (SQLSubqueryBuilder) throws -> SQLSubqueryBuilder) rethrows -> Self

Parameters

closure

A closure which builds a SELECT subquery using the provided builder.

Discussion

Example usage:

try await database.insert(into: "table")
    .columns("id", "foo", "bar")
    .select { $0
        .column(SQLLiteral.default, as: "id")
        .column("foo", table: "other")
        .column("bar", table: "other")
        .from("other")
        .where(SQLColumn("created_at", table: "other"), .greaterThan, SQLBind(someDate))
    }
    .run()