EdgeDB combines the power of SQL with graph database traversals. Write queries that follow relationships naturally — no JOINs, no ORMs, no N+1 problems.
Schema (Declarative, Not SQL DDL)
# dbschema/default.esdl
module default {
type User {
required name: str;
required email: str { constraint exclusive; };
multi posts: Post;
created_at: datetime { default := datetime_current(); };
}
type Post {
required title: str;
required content: str;
required author: User;
multi tags: Tag;
published: bool { default := false; };
}
type Tag {
required name: str { constraint exclusive; };
}
}
EdgeQL (The Query Language)
# Get users with their posts — NO JOINS needed
select User {
name,
email,
posts: {
title,
published,
tags: { name }
} filter .published = true
} filter .name ilike '%alice%';
# Insert with nested creation
insert Post {
title := 'EdgeDB Guide',
content := 'Learn EdgeDB...',
author := (select User filter .email = 'alice@example.com'),
tags := {
(insert Tag { name := 'database' } unless conflict on .name else (select Tag)),
(insert Tag { name := 'tutorial' } unless conflict on .name else (select Tag))
}
};
TypeScript Client
import { createClient } from 'edgedb';
const client = createClient();
// Fully typed queries
const users = await client.query(`
select User {
name,
post_count := count(.posts)
} order by .post_count desc
limit 10
`);
// With parameters
const user = await client.querySingle(`
select User { name, email, posts: { title } }
filter .id = <uuid>$id
`, { id: userId });
HTTP API
# EdgeDB exposes an HTTP endpoint
curl -X POST http://localhost:5656/branch/main/edgeql \
-H "Content-Type: application/json" \
-d '{"query": "select User { name, email } limit 5"}'
Migrations
edgedb migration create # Auto-generates migration from schema changes
edgedb migrate # Apply migrations
edgedb ui # Visual schema browser
Why This Matters
- No JOINs: Traverse relationships with dot notation
- No ORMs: Query language is expressive enough
- No N+1: Nested data in a single query
- Type-safe: Generate TypeScript types from schema
Need custom database tools or data modeling? I build developer tools. Check out my web scraping actors on Apify or reach out at spinov001@gmail.com for custom solutions.
Top comments (0)