npm drizzle-orm 0.29.4

latest releases: 0.34.0-bab5208, 0.34.0-f5d46d3, 0.34.0-06c725b...
7 months ago

New Features

🎉 Neon HTTP Batch

For more info you can check Neon docs

Example

const batchResponse: BatchType = await db.batch([
	db.insert(usersTable).values({ id: 1, name: 'John' }).returning({
		id: usersTable.id,
	}),
	db.insert(usersTable).values({ id: 2, name: 'Dan' }),
	db.query.usersTable.findMany({}),
	db.query.usersTable.findFirst({}),
]);
type BatchType = [
	{
		id: number;
	}[],
	NeonHttpQueryResult<never>,
	{
		id: number;
		name: string;
		verified: number;
		invitedBy: number | null;
	}[],
	{
		id: number;
		name: string;
		verified: number;
		invitedBy: number | null;
	} | undefined,
];

Improvements

Thanks to the database-js and PlanetScale teams, we have updated the default behavior and instances of database-js.

As suggested by the database-js core team, you should use the Client instance instead of connect():

import { Client } from '@planetscale/database';
import { drizzle } from 'drizzle-orm/planetscale-serverless';

// create the connection
const client = new Client({
	host: process.env['DATABASE_HOST'],
	username: process.env['DATABASE_USERNAME'],
	password: process.env['DATABASE_PASSWORD'],
});

const db = drizzle(client);

Warning: In this version, there are no breaking changes, but starting from version 0.30.0, you will encounter an error if you attempt to use anything other than a Client instance.

We suggest starting to change connections to PlanetScale now to prevent any runtime errors in the future.

Previously our docs stated to use connect() and only this function was can be passed to drizzle. In this realase we are adding support for new Client() and deprecating connect(), by suggesting from database-js team. In this release you will see a warning when trying to pass connect() function result:

Warning text

Warning: You need to pass an instance of Client:

import { Client } from "@planetscale/database";

const client = new Client({
  host: process.env["DATABASE_HOST"],
  username: process.env["DATABASE_USERNAME"],
  password: process.env["DATABASE_PASSWORD"],
});

const db = drizzle(client);

Starting from version 0.30.0, you will encounter an error if you attempt to use anything other than a Client instance.

Please make the necessary changes now to prevent any runtime errors in the future

Don't miss a new drizzle-orm release

NewReleases is sending notifications on new releases.