SQL is powerful but verbose. ORMs are convenient but limited. EdgeDB gives you a query language that feels like writing objects — with the power of PostgreSQL underneath.
What is EdgeDB?
EdgeDB is a database built on top of PostgreSQL that replaces SQL with EdgeQL — a modern query language that handles relationships, aggregations, and nested data naturally. It also auto-generates TypeScript types.
Why EdgeDB
1. EdgeQL vs SQL
-- SQL: Get users with their posts and comments count
SELECT u.id, u.name,
(SELECT json_agg(json_build_object(
'title', p.title,
'comment_count', (SELECT COUNT(*) FROM comments c WHERE c.post_id = p.id)
)) FROM posts p WHERE p.author_id = u.id) as posts
FROM users u WHERE u.name ILIKE '%alice%';
# EdgeQL: Same query
SELECT User {
name,
posts: {
title,
comment_count := count(.comments)
}
} FILTER .name ILIKE '%alice%';
2. Schema as Code
# dbschema/default.esdl
module default {
type User {
required name: str;
required email: str {
constraint exclusive;
};
multi posts := .<author[IS Post];
created_at: datetime {
default := datetime_current();
};
}
type Post {
required title: str;
required content: str;
required author: User;
multi comments: Comment;
multi tags: str;
published: bool {
default := false;
};
}
type Comment {
required body: str;
required author: User;
created_at: datetime {
default := datetime_current();
};
}
}
3. Auto-Generated TypeScript Client
npx @edgedb/generate edgeql-js
import e from './dbschema/edgeql-js';
import { createClient } from 'edgedb';
const client = createClient();
// Fully typed queries
const users = await e.select(e.User, (user) => ({
name: true,
email: true,
posts: (post) => ({
title: true,
comment_count: e.count(post.comments),
filter: e.op(post.published, '=', true),
}),
filter: e.op(user.name, 'ilike', '%alice%'),
})).run(client);
// users is typed as Array<{ name: string, email: string, posts: Array<{ title: string, comment_count: number }> }>
4. Built-in Auth
using extension auth;
module default {
type User {
required name: str;
required identity: ext::auth::Identity;
}
}
Email/password, OAuth, and magic links — built into the database.
5. Migrations
# Generate migration from schema changes
edgedb migration create
# Apply
edgedb migrate
# Squash migrations
edgedb migration squash
6. Built-in UI
edgedb ui
# Opens browser with:
# - Schema viewer
# - Data browser
# - Query editor with autocomplete
# - Migration history
EdgeDB vs PostgreSQL vs MongoDB
| EdgeDB | PostgreSQL | MongoDB | |
|---|---|---|---|
| Query language | EdgeQL | SQL | MQL |
| Relationships | First-class | JOINs | $lookup |
| Schema | SDL (strict) | DDL (strict) | Schemaless |
| TypeScript types | Auto-generated | Manual / Prisma | Manual |
| Nested queries | Natural | Subqueries/CTEs | Aggregation pipeline |
| Auth | Built-in | Extension | Atlas only |
| Migrations | Auto-generated | Manual | N/A |
Free Tier (EdgeDB Cloud)
| Feature | Free |
|---|---|
| Instances | 1 |
| Compute | Shared |
| Storage | 1GB |
| Bandwidth | 5GB/month |
Getting Started
# Install
curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
# Create project
edgedb project init
# Start UI
edgedb ui
The Bottom Line
EdgeDB makes PostgreSQL feel modern. EdgeQL is SQL without the pain, auto-generated TypeScript types eliminate manual mapping, and built-in auth saves weeks of development.
Need data tools? I build scraping solutions. Check my Apify actors or email spinov001@gmail.com.
Top comments (0)