A type-safe typescript SQL query builder
MIT License
Bot releases are visible (Hide)
Published by koskimas almost 3 years ago
Removed a magical UnionToIntersection
type that made it difficult to write generic helpers.
Published by koskimas almost 3 years ago
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()
)
Published by koskimas almost 3 years ago
Published by koskimas almost 3 years ago
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.
Published by koskimas almost 3 years ago
subQuery
method to selectFrom.QueryBuilder
type explicitly.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',
})
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)
}
}
})
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]))
Published by koskimas almost 3 years ago
Implement SQLite introspector.
Published by koskimas almost 3 years ago
Added support for SQLite using the better-sqlite3 library.
number | undefined
number
number
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')
.Published by koskimas almost 3 years ago
Use performance.now
instead of process.hrtime
to time query execution.
Published by koskimas almost 3 years ago
increments
method in the schema module is now called autoIncrement. You need to go through your migrations and use the new method.isPrimaryKey
are now renamed to primaryKey
. This only affects you if you've implemented your own plugins that transform the operation node tree.Published by koskimas almost 3 years ago
Added createView and dropView methods to the schema module.
Published by koskimas almost 3 years ago
Added operators ||, @@, @@@, !! and <->
Published by koskimas almost 3 years ago
Added node 16 requirement to package.json.
Published by koskimas almost 3 years ago
Added the &&
operator.
Published by koskimas almost 3 years ago
Published by koskimas almost 3 years ago