kysely

A type-safe typescript SQL query builder

MIT License

Downloads
1.9M
Stars
9.3K
Committers
109

Bot releases are visible (Hide)

kysely - 0.14.1

Published by koskimas almost 3 years ago

Removed a magical UnionToIntersection type that made it difficult to write generic helpers.

kysely - 0.14.0

Published by koskimas almost 3 years ago

Breaking changes

  • All expression methods in the schema module previously took a raw SQL string. Those all now take a db.raw instance instead for consistency.
// Before
db.schema
  .alterTable('person')
  .addCheckConstraint('some_constraint', 'a < b')

// Now
db.schema
  .alterTable('person')
  .addCheckConstraint('some_constraint', db.raw('a < b'))
  • onConflictDoNothing and onConflictUpdate methods have been replaced by a single onConflict method.
// Before
db.insertInto('pet').values(pet).onConflictUpdate('name', updates)

// Now
db.insertInto('pet').values(pet).onConflict(
  // Also see the `columns` and `constraint` methods.
  (oc) => oc.column('name').doUpdateSet(updates)
)
// Before
db.insertInto('pet').values(pet).onConflictDoNothing('name')

// Now
db.insertInto('pet').values(pet).onConflict(
  (oc) => oc.column('name').doNothing()
)
kysely - 0.13.0

Published by koskimas almost 3 years ago

Breaking changes

kysely - 0.12.2

Published by koskimas almost 3 years ago

  • Added withRecursive for recursive common table expressions.
  • Support node 14. Kysely will support the last two LTS versions from now on.
kysely - 0.12.1

Published by koskimas almost 3 years ago

Make jsdoc comments better accessible by copying them from the interfaces to the implementing classes. This is done automatically as a build step.

kysely - 0.12.0

Published by koskimas almost 3 years ago

Breaking changes

  • Renamed the subQuery method to selectFrom.
  • Created separate query builders for select, insert, update and delete queries. This is only a breaking change if you have used the QueryBuilder type explicitly.
kysely - 0.11.4

Published by koskimas almost 3 years ago

Support callback subqueries and raw expressions in insert queries:

db.with('jennifer', (db) => db
  .selectFrom('person')
  .where('first_name', '=', 'Jennifer')
  .select(['id', 'first_name'])
  .limit(1)
).insertInto('pet').values({
  id: db.generated,
  owner_id: (eb) => eb.subQuery('jennifer').select('id'),
  name: (eb) => eb.subQuery('jennifer').select('first_name'),
  species: 'cat',
})
kysely - 0.11.3

Published by koskimas almost 3 years ago

Support custom log function:

const db = new Kysely<Database>({
  dialect: new PostgresDialect(postgresConfig),
  log(event) {
    if (event.level === 'query') {
      console.log(event.query.sql)
      console.log(event.query.parameters)
    }
  }
})
kysely - 0.11.2

Published by koskimas almost 3 years ago

Accept a single raw argument in where, having and on statements. For example

where(db.raw('foo between ? and ?', [a, b]))
kysely - 0.11.1

Published by koskimas almost 3 years ago

Implement SQLite introspector.

kysely - 0.11.0

Published by koskimas almost 3 years ago

Added support for SQLite using the better-sqlite3 library.

Breaking changes

  • insert queries now return an InsertResult instead of number | undefined
  • update queries now return an UpdateResult instead of number
  • delete queries now return a DeleteResult instead of number
  • Number fields in QueryResult are now of type bigint to support large integers. Also the QueryResult. insertedPrimaryKey field has been renamed to insertId. QueryResult is only returned by completely raw queries like await db.raw('select * from person').
kysely - 0.10.1

Published by koskimas almost 3 years ago

Use performance.now instead of process.hrtime to time query execution.

kysely - 0.10.0

Published by koskimas almost 3 years ago

Breaking changes

  • increments method in the schema module is now called autoIncrement. You need to go through your migrations and use the new method.
  • Harmonised operation node flag names. Booleans like isPrimaryKey are now renamed to primaryKey. This only affects you if you've implemented your own plugins that transform the operation node tree.
kysely - 0.9.9

Published by koskimas almost 3 years ago

Added createView and dropView methods to the schema module.

kysely - 0.9.8

Published by koskimas almost 3 years ago

Added operators ||, @@, @@@, !! and <->

kysely - 0.9.7

Published by koskimas almost 3 years ago

Added node 16 requirement to package.json.

kysely - 0.9.6

Published by koskimas almost 3 years ago

Added the && operator.

kysely - 0.9.5

Published by koskimas almost 3 years ago

kysely - 0.9.4

Published by koskimas almost 3 years ago

kysely - 0.9.3

Published by koskimas almost 3 years ago

Added the union and unionAll methods.