Releases: drizzle-team/drizzle-orm
0.30.10
New Features
🎉 .if()
function added to all WHERE expressions
Select all users after cursors if a cursor value was provided
async function someFunction(categories: string[] = [], views = 0) {
await db
.select()
.from(users)
.where(
and(
gt(posts.views, views).if(views > 100),
inArray(posts.category, categories).if(categories.length > 0),
),
);
}
Bug Fixes
- Fixed internal mappings for sessions
.all
,.values
,.execute
functions in AWS DataAPI
0.30.9
- 🐛 Fixed migrator in AWS Data API
- Added
setWhere
andtargetWhere
fields to.onConflictDoUpdate()
config in SQLite instead of singlewhere
field - 🛠️ Added schema information to Drizzle instances via
db._.fullSchema
0.30.8
⚠️ Only available indrizzle-orm
for now,drizzle-kit
support will arrive soon
import { pgSchema } from 'drizzle-orm/pg-core';
const mySchema = pgSchema('mySchema');
const colors = mySchema.enum('colors', ['red', 'green', 'blue']);
- 🎉 Changed D1
migrate()
function to use batch API (#2137) - 🐛 Split
where
clause in Postgres.onConflictDoUpdate
method intosetWhere
andtargetWhere
clauses, to support bothwhere
cases inon conflict ...
clause (fixes #1628, #1302 via #2056) - 🐛 Fixed query generation for
where
clause in Postgres.onConflictDoNothing
method, as it was placed in a wrong spot (fixes #1628 via #2056) - 🐛 Fixed multiple issues with AWS Data API driver (fixes #1931, #1932, #1934, #1936 via #2119)
- 🐛 Fix inserting and updating array values in AWS Data API (fixes #1912 via #1911)
Thanks @hugo082 and @livingforjesus!
0.30.7
0.30.6
New Features
🎉 PGlite driver Support
PGlite is a WASM Postgres build packaged into a TypeScript client library that enables you to run Postgres in the browser, Node.js and Bun, with no need to install any other dependencies. It is only 2.6mb gzipped.
It can be used as an ephemeral in-memory database, or with persistence either to the file system (Node/Bun) or indexedDB (Browser).
Unlike previous "Postgres in the browser" projects, PGlite does not use a Linux virtual machine - it is simply Postgres in WASM.
Usage Example
import { PGlite } from '@electric-sql/pglite';
import { drizzle } from 'drizzle-orm/pglite';
// In-memory Postgres
const client = new PGlite();
const db = drizzle(client);
await db.select().from(users);
There are currently 2 limitations, that should be fixed on Pglite side:
0.30.5
New Features
🎉 $onUpdate
functionality for PostgreSQL, MySQL and SQLite
Adds a dynamic update value to the column.
The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
If no default
(or $defaultFn
) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.
Note: This value does not affect the
drizzle-kit
behavior, it is only used at runtime indrizzle-orm
.
const usersOnUpdate = pgTable('users_on_update', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
updateCounter: integer('update_counter').default(sql`1`).$onUpdateFn(() => sql`update_counter + 1`),
updatedAt: timestamp('updated_at', { mode: 'date', precision: 3 }).$onUpdate(() => new Date()),
alwaysNull: text('always_null').$type<string | null>().$onUpdate(() => null),
});
Fixes
- [BUG]: insertions on columns with the smallserial datatype are not optional - #1848
Thanks @Angelelz and @gabrielDonnantuoni!
0.30.4
New Features
🎉 xata-http driver support
According their official website, Xata is a Postgres data platform with a focus on reliability, scalability, and developer experience. The Xata Postgres service is currently in beta, please see the Xata docs on how to enable it in your account.
Drizzle ORM natively supports both the xata
driver with drizzle-orm/xata
package and the postgres
or pg
drivers for accessing a Xata Postgres database.
The following example use the Xata generated client, which you obtain by running the xata init CLI command.
pnpm add drizzle-orm @xata.io/client
import { drizzle } from 'drizzle-orm/xata-http';
import { getXataClient } from './xata'; // Generated client
const xata = getXataClient();
const db = drizzle(xata);
const result = await db.select().from(...);
You can also connect to Xata using pg
or postgres.js
drivers
0.30.3
- 🎉 Added raw query support (
db.execute(...)
) to batch API in Neon HTTP driver - 🐛 Fixed
@neondatabase/serverless
HTTP driver types issue (#1945, neondatabase/serverless#66) - 🐛 Fixed sqlite-proxy driver
.run()
result (#2038)
0.30.2
Improvements
LibSQL migrations have been updated to utilize batch execution instead of transactions. As stated in the documentation, LibSQL now supports batch operations
A batch consists of multiple SQL statements executed sequentially within an implicit transaction. The backend handles the transaction: success commits all changes, while any failure results in a full rollback with no modifications.
Bug fixed
- [Sqlite] Fix findFirst query for bun:sqlite #1885 - thanks @shaileshaanand
0.30.1
New Features
🎉 OP-SQLite driver Support
Usage Example
import { open } from '@op-engineering/op-sqlite';
import { drizzle } from 'drizzle-orm/op-sqlite';
const opsqlite = open({
name: 'myDB',
});
const db = drizzle(opsqlite);
await db.select().from(users);
For more usage and setup details, please check our op-sqlite docs
Bug fixes
- Migration hook fixed for Expo driver