0.4.0
What's Changed
- The
@Schemamacro now automatically adds conformance toSchemaProtocolandIDSchemaProtocol. - Types with the
@Schemamacro can now be used as regular types, which was not possible before.- Along with this change, the
Codablerequirement has been added toSchemaProtocol.
- Along with this change, the
- A query syntax utilizing type composition has been added.
// --- Before
let userRow = try await sql.select()
.column(UserTable.id)
.column(UserTable.email)
.column(UserTable.passwordHash)
.from(UserTable.self)
.where(UserTable.id, .equal, userID)
.first()!
let userID = try userRow.decode(typed: UserTable.id)
let currentEmail = try userRow.decode(typed: UserTable.email)
let passwordHash = try userRow.decode(typed: UserTable.passwordHash)
// --- After
let userRow = try await sql.selectWithColumns {
UserTable.id
UserTable.email
UserTable.passwordHash
}
.from(UserTable.tableName)
.where(UserTable.id, .equal, userID)
.first()!
// We can access selected columns with type safety! (Powered by snowman generics and KeyPath dynamic member lookup and resultBuilder.)
let userID = userRow.id
let currentEmail = userRow.email
let passwordHash = userRow.passwordHashFull Changelog: 0.3.0...0.4.0