Skip to main content
db is a Drizzle ORM instance connected to your project’s D1 database. Import it from edgespark inside your server code.

Select

server/src/index.ts

Insert

server/src/index.ts

Update and delete

server/src/index.ts

Relational queries

If you define relations in server/src/defs/db_relations.ts, you can use Drizzle’s relational query helpers:
server/src/index.ts

Batch operations

Execute multiple statements atomically with db.batch():
server/src/index.ts
Use db.batch() instead of multi-statement transactions. See platform limits for the current batch limit and other database constraints.

See also

Use the database

How to define schema, generate migrations, and query D1 in the current scaffold.

Platform limits

Runtime SQL, batch, and deployment constraints that affect database code.
Last modified on April 7, 2026