<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/mizzle---a-drizzle-like-orm-for-dynamodb-wgdrljukd" -->

---
title: Mizzle - A drizzle like ORM for DynamoDB | daily.dev
description: Mizzle is a new type-safe ORM for DynamoDB inspired by Drizzle&#x27;s developer experience. It provides a fluent API for defining schemas, entities, and...
canonical: https://daily.dev/posts/mizzle---a-drizzle-like-orm-for-dynamodb-wgdrljukd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Mizzle - A drizzle like ORM for DynamoDB | daily.dev
og:description: Mizzle is a new type-safe ORM for DynamoDB inspired by Drizzle&#x27;s developer experience. It provides a fluent API for defining schemas, entities, and...
og:url: https://daily.dev/posts/mizzle---a-drizzle-like-orm-for-dynamodb-wgdrljukd
og:image: https://api.daily.dev/og/posts/wGDrLjUKD.png
og:image:alt: Mizzle - A drizzle like ORM for DynamoDB
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Mizzle - A drizzle like ORM for DynamoDB

**[Lucas A. Ouverney](https://daily.dev/sources/l03zp6g7x)** · [@realfakenerd](https://daily.dev/realfakenerd) · 4 min read · 1 upvotes · 0 comments

## Summary

Mizzle is a new type-safe ORM for DynamoDB inspired by Drizzle's developer experience. It provides a fluent API for defining schemas, entities, and relationships with TypeScript type inference. Key features include relational queries, batch operations, transactions, and automatic routing between GetItem, Query, and Scan operations. The library separates physical table definitions from logical entities, uses UUID v7 for time-sortable keys, and includes a CLI tool for table creation.

## Content

Hi guys!

# 🌧️ mizzle 

Wanted to share this package I made. 

It's the ORM Dynamo needed, it was born from the need of having the simplicity of Drizzle with Dynamo.

So I thought to myself, why not make an ORM and make it feels like drizzle.

With that in mind mizzle was born.

Mizzle provides a type-safe, fluent API for interacting with DynamoDB, supporting relational queries, batch operations, and transactions.

## Key Features

- **Type-Safe Schema Definition**: Define your tables and entities with strict TypeScript types.
- **Fluent Query Builder**: precise API for `insert`, `select`, `update`, and `delete` operations.
- **Relational Queries**: Query related entities with `db.query`.
- **Batch Operations**: `batchGet` and `batchWrite` support.
- **Transactions**: Atomic operations using `db.transaction`.
- **Automatic Type Inference**: `InferSelectModel` and `InferInsertModel` utilities.

> Skip this with the [way less boring docs](https://mizzle-docs.vercel.app)

## 🚀 Installation

```bash
npm install @aurios/mizzle
# or
bun add @aurios/mizzle
```

## Get Started

### Defining the Table

In DynamoDB, you first need a physical table. Mizzle separates the definition of the physical table structure (PK, SK, Indexes) from the logical entities that live within it and with this making your database well organized and easier to reason about.

```ts
import { dynamoTable, string } from "@aurios/mizzle";

// This matches your actual DynamoDB table configuration
export const myTable = dynamoTable("JediOrder", {
  pk: string("pk"), // The partition key attribute name
  sk: string("sk"), // The sort key attribute name (optional)
});
```

### Defining the Entity

An Entity represents your data model (e.g., an user, an item on an user). You map the Entity to a Physical Table and define how its keys are generated, so every entity looks kinda like an separated table.

```ts
import { dynamoEntity, string, uuid, number, enum, date, prefixKey, staticKey } from "@aurios/mizzle";

export const jedi = dynamoEntity(
  myTable,
  "Jedi",
  {
    id: uuid(), // Automatically generates a v7 UUID
    name: string(),
    homeworld: string()
  },
  (cols) => ({
    // PK will look like "JEDI#<uuid>"
    pk: prefixKey("JEDI#", cols.id),
    // SK will be a static string "PROFILE"
    sk: staticKey("PROFILE"),
  }),
);

export const jediRank = dynamoEntity(
  myTable,
  'JediRank',
  {
    jediId: uuid(),
    position: string().default('initiate'),
    joinedCouncilDate: string(),
  },
  (cols) => ({
    // Same as the jedi so they can be related
    pk: prefixKey('JEDI#', cols.jediId),
    // RANK#initiate
    sk: prefixKey('RANK#', cols.position),
  })
)
```

> The UUID V7 was chosen for better sorting, since the values are time-sortable with 1 millisecond precision.

### Define the Relations

Relationships in Mizzle are established using the defineRelations function. This step creates a logical map of how your entities interact, enabling you to perform powerful relational queries—such as fetching a Jedi along with their entire rank history—in a single operation.

```ts
import { defineRelations } from "@aurios/mizzle";
import * as schema from "./schema";

export const relations = defineRelations(schema, (r) => ({
  jedi: {
    // A Jedi could've a lot of ranks throughout his year
    ranks: r.many.jediRank({
      fields: [r.jedi.id],
      references: [r.jediRank.jediId],
    }),
  },
  jediRank: {
    // Every registry points to one Jedi only
    member: r.one.jedi({
      fields: [r.jediRank.jediId],
      references: [r.jedi.id],
    }),
  },
}));
```

### Initialization

Initialize the mizzle client by passing it an instance of the standard AWS DynamoDBClient and the relations we just defined.

```ts
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { mizzle } from "@aurios/mizzle";
import { relations } from "./relations";

const client = new DynamoDBClient({ region: "us-east-1" });
export const db = mizzle({ client, relations });
```

### Query

Now you can use the fluent API to interact with your data in the best way possible.

#### Insert Data

```typescript
// api/jedi/new.ts
import { jedi } from "$lib/schema.ts";

const newJedi = await db
  .insert(jedi)
  .values({
    name: "Luke Skywalker",
    homeworld: "Tatooine",
  })
  .returning();

console.log(newJedi.id); // The auto-generated UUID
```

#### Select Data

Mizzle intelligently routes your request to `GetItem`, `Query`, or `Scan` based on the filters you provide.

```typescript
// /api/jedi/get.ts
import { jedi } from "$lib/schema.ts";
import { eq } from "@aurios/mizzle";

// This will use GetItem because both PK and SK are fully resolved
const user = await db.select().from(jedi).where(eq(jedi.id, "some-uuid")).execute();
```

## Mizzling

This will work if you already has a DynamoDB table with data in it. If you want to create a new table with the schema you defined, you can use the [`mizzling`](https://www.npmjs.com/package/@aurios/mizzling) CLI.

I truly hope this helps someone else as it helps me with my other projects ❤️

## Similar posts on daily.dev

- [Drizzle ORM: an introduction](https://daily.dev/posts/drizzle-orm-an-introduction-ddzeiduom) · Flavio Copes · 7 upvotes · 2 comments

---

Tags: [#aws](https://daily.dev/tags/aws), [#database](https://daily.dev/tags/database), [#typescript](https://daily.dev/tags/typescript), [#aws-dynamodb](https://daily.dev/tags/aws-dynamodb)

[View this post on daily.dev](https://daily.dev/posts/mizzle---a-drizzle-like-orm-for-dynamodb-wgdrljukd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/mizzle---a-drizzle-like-orm-for-dynamodb-wgdrljukd","headline":"Mizzle - A drizzle like ORM for DynamoDB","text":"Mizzle is a new type-safe ORM for DynamoDB inspired by Drizzle's developer experience. It provides a fluent API for defining schemas, entities, and relationships with TypeScript type inference. Key features include relational queries, batch operations, transactions, and automatic routing between GetItem, Query, and Scan operations. The library separates physical table definitions from logical entities, uses UUID v7 for time-sortable keys, and includes a CLI tool for table creation.","url":"https://daily.dev/posts/mizzle---a-drizzle-like-orm-for-dynamodb-wgdrljukd","datePublished":"2026-01-29T22:45:17.386Z","dateModified":"2026-01-29T22:45:36.944Z","author":{"@type":"Person","name":"Lucas A. Ouverney","url":"https://daily.dev/realfakenerd","image":"https://avatars.githubusercontent.com/u/16668109?v=4","description":"5/100","worksFor":{"@type":"Organization","name":"Apsa","logo":"https://res.cloudinary.com/daily-now/image/upload/s--U0d9Dojp--/f_auto/v1725280420/companies/apsa"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":3565}},"image":"https://media.daily.dev/image/upload/s--vQhxXs0U--/f_auto/v1769726717/posts/wGDrLjUKD?_a=BAMAMiiu0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/l03zp6g7x","name":"Lucas A. Ouverney"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lucas A. Ouverney","item":"https://daily.dev/sources/l03zp6g7x"},{"@type":"ListItem","position":3,"name":"Mizzle - A drizzle like ORM for DynamoDB"}]}
```

