Decouple associations from TableRecord

Associations is generic for type safety, not for defining the association (just as QueryInterfaceRequest)
This commit is contained in:
Gwendal Roué committed 2021-01-23 09:48:18 +01:00
1 parent bc5ba1fda5
commit 8bf9e5e30f
9 files changed
+62 -26

No files matched your search

+13
View File
@@ -186,6 +186,19 @@ struct SQLRelation {
}
}
extension SQLRelation {
/// Convenience factory methods which selects all rows from a table.
static func all(
fromTable tableName: String,
selection: @escaping (Database) -> [SQLSelectable] = { _ in [AllColumns()] })
-> Self
{
SQLRelation(
source: SQLSource(tableName: tableName, alias: nil),
selectionPromise: DatabasePromise(selection))
}
}
extension SQLRelation: Refinable {
func select(_ selection: @escaping (Database) throws -> [SQLSelectable]) -> Self {
with(\.selectionPromise, DatabasePromise(selection))