Skip to content

Releases: igalklebanov/kysely-surrealdb

v0.7.4

22 May 10:12
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.7.3...v0.7.4

v0.7.3

20 May 09:05
Compare
Choose a tag to compare

New Features:

  • Added kysely-surrealdb/helpers, first batch of helpers is basic types as SurrealQL literals.
import { FALSE, NONE, NULL, TRUE } from 'kysely-surrealdb/helpers'

await db.create('person:123').set({
  married: FALSE,
  age: NONE,
  children: NULL,
  excited: TRUE,
}).execute()
// create person:123 set married = false, age = none, children = null, excited = true;

Other changes:

  • bumped surrealdb.js peer dependency back to latest (0.7.3) as they have reverted their dependency changes.
  • bumped kysely peer dependency to latest (0.24.2).

Full Changelog: v0.7.1...v0.7.3

v0.7.1

19 May 11:12
Compare
Choose a tag to compare

So apparently surrealdb.js has introduced some breaking changes at 0.6.0 and 0.7.x that make kysely-surrealdb unusable.

This patch version makes sure you stay on surrealdb.js v0.5.0 while we investigate further.

Full Changelog: v0.7.0...v0.7.1

v0.7.0 - `WebSockets` Dialect's Revenge.

30 Mar 01:51
Compare
Choose a tag to compare
  • Added SurrealDbWebSocketsDialect
import {Kysely} from 'kysely'
import {SurrealDatabase, SurrealDbWebSocketsDialect, type SurrealEdge} from 'kysely-surrealdb'
import Surreal from 'surrealdb.js'

interface Database {
  person: {
    first_name: string | null
    last_name: string | null
    age: number
  }
  own: SurrealEdge<{
    time: {
      adopted: string
    } | null
  }>
  pet: {
    name: string
    owner_id: string | null
  }
}

// with username and password
const db = new Kysely<SurrealDatabase<Database>>({
  dialect: new SurrealDbWebSocketsDialect({
    database: '<database>',
    Driver: Surreal,
    hostname: '<hostname>', // e.g. 'localhost:8000'
    namespace: '<namespace>',
    password: '<password>',
    // scope: '<scope>', // optional
    username: '<username>',
  }),
})

// alternatively, with a token
const dbWithToken = new Kysely<SurrealDatabase<Database>>({
  dialect: new SurrealDbWebSocketsDialect({
    database: '<database>',
    Driver: Surreal,
    hostname: '<hostname>', // e.g. 'localhost:8000'
    namespace: '<namespace>',
    token: '<token>',
  }),
})

Note: transactions with Kysely's built-in methods don't work yet.

v0.6.0 - Rise of the `IF ELSE` statement.

26 Mar 20:52
Compare
Choose a tag to compare
  • Added IF ELSE statement support. Try out SurrealKysely.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.