mcu-sandbox
mcu-sandbox copied to clipboard
A movie schema sandbox for playing with EdgeDB and the EdgeQL query builder, pre-loaded with MCU data
The EdgeDB MCU sandbox 🦹
This is a sandbox for playing with EdgeDB and the EdgeQL query builder.
It includes a simple movie database schema (dbschema/default.esdl) and a sample dataset (seed.ts) containing the movies and shows in the Marvel Cinematic Universe (last update: July 2022).
Setup
1. Install the EdgeDB CLI
# macOS/Linux
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
# windows
$ iwr https://ps1.edgedb.com -useb | iex
2. Clone the repo
$ git clone [email protected]:edgedb/mcu-sandbox.git
$ cd mcu-sandbox
3. Initialize the EdgeDB project
edgedb project init
Then follow the prompts. This step spins up a local EdgeDB instance and applies the migrations inside dbschema/migrations.
4. Setup project
$ npm install # install dependencies
$ npx edgeql-js # generate query builder
$ npx tsx seed.ts # seed the database
5. Start writing queries!
Write a query in script.ts and execute it like so:
$ npm run dev
This starts a watcher, so every time you update and save script.ts, the script will be re-run.
Evolving the schema
- Update the schema in
dbschema/default.esdl - Generate a new migration with
edgedb migration create - Follow the interactive prompts
- Apply the migration with
edgedb migrate - Regenerate the query builder with
npx edgeql-js
File structure
The sandbox is a simple project designed to showcase the query builder.
script.ts- a simple script you can update to play with the query builderdbschema/default.esdl- the schema filedbschema/migrations- the migrations directorydbschema/edgeql-js- the default location of the generated query builder