Skip to content

0.4.0

Choose a tag to compare

@sidepelican sidepelican released this 29 Aug 08:46
· 5 commits to main since this release
a285700

What's Changed

  • The @Schema macro now automatically adds conformance to SchemaProtocol and IDSchemaProtocol.
  • Types with the @Schema macro can now be used as regular types, which was not possible before.
    • Along with this change, the Codable requirement has been added to SchemaProtocol.
  • 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.passwordHash

Full Changelog: 0.3.0...0.4.0