First, install Gel if you haven’t already.
Use
bun init to create a fresh project.
terminal
Initialize a Gel instance for the project with the Gel CLI. The
gel project init command creates a gel.toml file in the project root.
terminal
To check that the database is running, open a REPL and run a query.
terminal
\quit to exit the REPL.
terminal
Next, define a schema. The
gel project init command already created a dbschema/default.esdl file to hold it.
File Tree
Open that file and paste the following contents.
default.esdl
Then generate and apply an initial migration.
terminal
terminal
With the schema applied, query the database with Gel’s JavaScript client library. Install the client library and Gel’s codegen CLI, then create a
seed.ts file.
terminal
Paste the following code into
seed.ts.
The client auto-connects to the database. The script inserts a few movies with the .execute() method, using EdgeQL’s for expression to turn the bulk insert into a single query.
Then run this file with Bun.
terminal
Gel implements several code generation tools for TypeScript. To write typesafe queries against the seeded database, generate the EdgeQL query builder with
@gel/generate.
terminal
In
index.ts, import the generated query builder from ./dbschema/edgeql-js and write a select query.
Run the file with Bun to see the movies you inserted.
terminal
See the Gel docs.