Drizzle ORM

Drizzle is a good friend who’s there for you when necessary and doesn’t bother when you need some space.

Drizzle ORM is a headless TypeScript ORM with a head 🐲

It looks and feels simple, performs on day 1000 of your project, lets you do things your way, and is there when you need it.

It’s the only ORM with both relational and SQL-like query APIs, providing you best of both worlds when it comes to accessing your relational data. Drizzle is lightweight, performant, typesafe, non lactose, gluten-free, sober, flexible and serverless-ready by design. Drizzle is not just a library, it’s an experience 🤩

Drizzle bestofjs

Headless ORM?

First and foremost, Drizzle is a library and a collection of complementary opt-in tools.

ORM stands for object relational mapping, and developers tend to call Django-like or Spring-like tools an ORM. We trully believe it’s a misconception based on legacy nomenclature and we call them data frameworks.

️💔

With data frameworks you have to build projects around them and not with them.

Drizzle lets you build your project the way you want, without interfering with your project or structure.

Using Drizzle you can define & manage database schemas in TypeScript, access your data in a SQL-like or relational way, and take advantage of opt in tools to push your developer experience through the roof 🤯

Why SQL-like?

If you know SQL — you know Drizzle.

Other ORMs and data frameworks tend to deviate/abstract you away from SQL which leads to a double learning curve — needing to know both SQL and the framework’s API.

Drizzle is the opposite. We embrace SQL and built Drizzle to be SQL-like at its core, so you can have zero to none learning curve and access to the full power of SQL.

We bring all the familiar SQL schema, queries, automatic migrations and one more thing

index.ts
schema.ts
migration.sql
// Access your data
await db
  .select()
  .from(countries)
  .leftJoin(cities, eq(cities.countryId, countries.id))
  .where(eq(countries.id, 10))
// manage your schema
export const countries = pgTable('countries', {
  id: serial('id').primaryKey(),
  name: varchar('name', { length: 256 }),
});

export const cities = pgTable('cities', {
  id: serial('id').primaryKey(),
  name: varchar('name', { length: 256 }),
  countryId: integer('country_id').references(() => countries.id),
});
-- generate migrations
CREATE TABLE IF NOT EXISTS "countries" (
  "id" serial PRIMARY KEY NOT NULL,
  "name" varchar(256)
);

CREATE TABLE IF NOT EXISTS "cities" (
  "id" serial PRIMARY KEY NOT NULL,
  "name" varchar(256),
  "country_id" integer
);

ALTER TABLE "cities" ADD CONSTRAINT "cities_country_id_countries_id_fk" FOREIGN KEY ("country_id") REFERENCES "countries"("id") ON DELETE no action ON UPDATE no action;

Why not SQL-like?

We’re always striving for a perfectly balanced solution, and while SQL-like does cover 100% of the needs, there’re certain common scenarios where you can query data in a better way.

We’ve built Queries API for you, so you can fetch relational nested data from the database in the most convenient and performant way, and never think about joins and data mapping.

Drizzle always outputs exactly 1 SQL query — feel free to use it with serverless databases and never worry about performance or roundtrip costs!

const result = await db.query.users.findMany({
  with: {
    posts: true
  },
});

Serverless?

🥳

Best part is no part — Drizzle has exactly 0 dependencies!

Drizzle is slim an Serverless ready

Drizzle ORM is dialect specific, slim, performant and serverless ready by design.

We’ve spent a lot of time to make sure you have best in class SQL dialects support — Postgres, MySQL, or any other dialect-specific stuff.

Drizzle is operating natively through industry standard database drivers. We support all major PostgreSQL, MySQL or SQLite drivers out there and we’re adding new ones really fast.

Welcome on board!

More and more companies adopt Drizzle into production, experiencing immense benefits in both DX and performance.

We’re always there to help, so don’t hesitate to reach out — we’ll gladly assist you in your Drizzle journey!

We have an outstanding Discord community and welcome all builders to our Twitter.

Now go build something awesome with Drizzle and your PostgreSQL, MySQL or SQLite 🚀

Video Showcase