v0.6.0 - Rise of the `IF ELSE` statement.
- Added
IF ELSEstatement support. Try outSurrealKysely.ifThen(condition, expression).
const accounts = await db
.ifThen(sql`${scope} = ${sql.literal('admin')}`, db.selectFrom('account').selectAll())
.elseIfThen(sql`${scope} = ${sql.literal('user')}`, sql<Account[]>`(select * from ${auth}.account)`)
.else(sql<[]>`[]`)
.end()
.execute()const result = await db.updateTable('person').set({
railcard: db
.ifThen(sql`${sql.ref('age')} <= 10`, sql.literal('junior'))
.elseIfThen(sql`${sql.ref('age')} <= 21`, sql.literal('student'))
.elseIfThen(sql`${sql.ref('age')} >= 65`, sql.literal('senior'))
.else(sql`null`)
.end(),
})
.executeTakeFirstOrThrow()These would be very nice once the new Kysely ExpressionBuilder capabilities are released!
- Fixed a bug where update/insert/delete results might not have had correct affected rows.
- Deprecated a bunch of
call,if,withPlugin, etc methods to align with Kysely's changes (adding$prefix to utility non-sql methods). - Bumped Kysely peer dependency to
>= 0.23.5.