# Using D1

This page covers how to use Cloudflare D1 with Drizzle ORM in your Quickback Stack application.

## Drizzle Queries

The generated API uses Drizzle ORM for all database operations:

```typescript
import { db } from '../db';
import { rooms } from '../schema';
import { eq } from 'drizzle-orm';

// Select
const allRooms = await db.select().from(rooms);

// Where clause
const room = await db.select().from(rooms).where(eq(rooms.id, id));

// Insert
await db.insert(rooms).values({ name: 'Conference A' });
```

## Dual-DB Mode

Quickback supports separate databases for auth and application data, useful for multi-tenant SaaS apps.

## Migrations

Migrations are generated by the compiler using `drizzle-kit generate`. Apply them with:

```bash
npx wrangler d1 migrations apply my-db
```

## Related

- [D1 Setup](/platform/database/d1) — Bindings and wrangler config
- [Schema](/define/schema) — Defining your database schema
