Skip to main content
Gel (formerly EdgeDB) is a graph-relational database powered by Postgres under the hood. It provides a declarative schema language, migrations system, and object-oriented query language, in addition to supporting raw SQL queries. It solves the object-relational mapping problem at the database layer, eliminating the need for an ORM library in your application code.
First, install Gel if you haven’t already.

Use bun init to create a fresh project.
terminal

We’ll use the Gel CLI to initialize a Gel instance for our project. This creates a gel.toml file in our project root.
terminal

To see if the database is running, let’s open a REPL and run a query.
terminal
Then run \quit to exit the REPL.
terminal

With the project initialized, we can define a schema. The gel project init command already created a dbschema/default.esdl file to contain our schema.
File Tree

Open that file and paste the following contents.
default.esdl

Then generate and apply an initial migration.
terminal
terminal

With our schema applied, let’s execute some queries using Gel’s JavaScript client library. We’ll install the client library and Gel’s codegen CLI, and create a seed.ts.file.
terminal

Paste the following code into seed.ts. The client auto-connects to the database. We insert a couple movies using the .execute() method. We will use EdgeQL’s for expression to turn this bulk insert into a single optimized query.
seed.ts

Then run this file with Bun.
terminal

Gel implements a number of code generation tools for TypeScript. To query our newly seeded database in a typesafe way, we’ll use @gel/generate to code-generate the EdgeQL query builder.
terminal

In index.ts, we can import the generated query builder from ./dbschema/edgeql-js and write a select query.
index.ts

Running the file with Bun, we can see the list of movies we inserted.
terminal

For complete documentation, refer to the Gel docs.