beta feature

Almost complete feature but still under development. There may be changes as we address issues and feedback. Use with caution.

Drizzle with Xata

Drizzle is a TypeScript ORM that is focused on type safety and closely follows the SQL syntax.

Install both Drizzle and with the Xata client. You can use the following package managers:

npm install drizzle-orm

You can use Drizzle with a Xata, as demonstrated in the following examples:

import { pgTable, text } from 'drizzle-orm/pg-core';
import { drizzle } from '';
import { eq } from 'drizzle-orm';
import { getXataClient } from './xata'; // Generated client
const xata = getXataClient();
const drivers = pgTable('drivers', {
  id: text('id').primaryKey(),
  surname: text('surname'),
  forename: text('forename'),
  nationality: text('nationality')
const db = drizzle(xata);
const result = await db
  .select({ surname: drivers.surname, forename: drivers.forename })
  .where(eq(drivers.nationality, 'Spanish'))

The code imports required modules from the drizzle-orm and libraries. It also brings in the eq function from drizzle-orm for value comparison and the getXataClient function from a local xata module. The getXataClient function is used to acquire an instance of the Xata client.

Currently, we recommend manually defining the schema like in the example above. We are working on utility functions to automatically generate the Drizzle model from the Xata database schema.

  • Drizzle migrations are not supported yet
  • Transactions are not supported yet