### Start and Rollback Transaction Example Source: https://docs.geldata.com/reference/reference/edgeql/tx_start.md Demonstrates how to start a transaction, execute a command within it, and then roll back the changes. ```edgeql start transaction; select 'Hello World!'; rollback; ``` -------------------------------- ### Project Setup and Basic Gel Usage Source: https://docs.geldata.com/reference/using/js.md Set up a new project, install Gel, and demonstrate basic client creation and query execution with different cardinality options. ```bash mkdir gel-js-example cd gel-js-example npm init -y npm install gel npm install --save-dev @gel/generate npx gel project init --non-interactive touch index.mjs ``` ```javascript import { createClient } from "gel"; import assert from "node:assert"; const client = createClient(); // get connection details automatically // Query always returns an array of result, even for single object queries const queryResult = await client.query("select 1"); assert.equal(queryResult, [1]); // querySingle will throw an error if the query returns more than one row const singleQueryResult = await client.querySingle("select 1"); assert.equal(singleQueryResult, 1); // queryRequired will throw an error if the query returns no rows const requiredQueryResult = await client.queryRequired("select 1"); assert.equal(requiredQueryResult, 1); // queryRequiredSingle will throw an error if // - the query returns more than one row // - the query returns no rows const requiredSingleQueryResult = await client.queryRequiredSingle("select 1"); assert.equal(requiredSingleQueryResult, 1); ``` -------------------------------- ### Install Gel Client for Go Source: https://docs.geldata.com/learn/clients.md Get the Gel client library for Go using go get. ```bash $ go get github.com/geldata/gel-go ``` -------------------------------- ### Full Documentation Build and Development Server Source: https://docs.geldata.com/resources/guides/contributing/documentation.md Clone the website repository and follow installation instructions. Run 'yarn dev' to start a development server that builds all documentation. Note that auto-reload is not supported; manual browser reloads are required. ```bash yarn dev ``` -------------------------------- ### Install Dependencies for Flask-Gel API Source: https://docs.geldata.com/resources/guides/tutorials/rest_apis_with_flask.md Clone the example repository, set up a Python virtual environment, and install the necessary Python packages including gel, flask, and httpx. ```bash git clone git@github.com:geldata/gel-examples.git cd gel-examples/flask-crud python -m venv myvenv source myvenv/bin/activate pip install gel flask 'httpx[cli]' ``` -------------------------------- ### Start Development Server Source: https://docs.geldata.com/learn/tutorials/gel_drizzle_booknotes.md Command to start the Next.js development server. ```bash npm run dev ``` -------------------------------- ### Install Gel Client and Generator with bun Source: https://docs.geldata.com/reference/using/js.md Install the database client and optional generator packages using bun. ```bash bun add gel # database client bun add --dev @gel/generate # generators ``` -------------------------------- ### Install Gel Client and Generator with deno Source: https://docs.geldata.com/reference/using/js.md Install the database client and optional generator packages using deno. ```bash deno add npm:gel # database client den add --dev npm:@gel/generate # generators ``` -------------------------------- ### Example: Generate default salt Source: https://docs.geldata.com/reference/stdlib/pgcrypto.md This example shows how to generate a salt using the default settings. ```edgeql-repl db> select ext::pgcrypto::gen_salt(); {'$2a$06$5D2rBj3UY5/UYvPIUNILvu'} ``` -------------------------------- ### Install Dependencies Source: https://docs.geldata.com/resources/guides/tutorials/rest_apis_with_fastapi.md Set up a Python virtual environment and install the necessary dependencies including gel, fastapi, httpx, and uvicorn. ```bash python -m venv myvenv source myvenv/bin/activate pip install gel fastapi 'httpx[cli]' uvicorn ``` -------------------------------- ### Install Gel Server CLI Source: https://docs.geldata.com/reference/using/cli/gel_server/gel_server_install.md Use this command to install the Gel server. Options allow for interactive installation, installing nightly builds, or specifying a particular version. ```cli gel server install [] ``` -------------------------------- ### Start Gel REPL Source: https://docs.geldata.com/learn/quickstart/setup/fastapi.md Start the Gel REPL from the project root to explore the empty database and run initial queries. ```sh $ uvx gel ``` -------------------------------- ### Initialize Gel Client and Query Database Source: https://docs.geldata.com/learn/quickstart/connecting/nextjs Initializes the Gel client and executes a simple static query to the database. This example shows the basic setup for connecting and querying without needing explicit connection details, as Gel handles this through project configuration and environment variables. ```typescript import { createClient } from "gel"; const client = createClient(); async function main() { console.log(await client.query("select 'Hello from Gel!';")); } main().then( () => process.exit(0), (err) => { console.error(err); process.exit(1); } ); ``` -------------------------------- ### Install Gel Client Source: https://docs.geldata.com/resources/guides/tutorials/nextjs_pages_router.md Install the Gel client library using npm. This is required for interacting with the database. ```bash npm install gel ``` -------------------------------- ### Install Gel Client Source: https://docs.geldata.com/resources/guides/tutorials/trpc.md Install the Gel client package using your preferred package manager. ```bash pnpm add gel # or yarn add gel # or npm install gel # or bun add gel ``` -------------------------------- ### Install Gel Client and Generator with npm Source: https://docs.geldata.com/reference/using/js.md Install the database client and optional generator packages using npm. ```bash npm install --save-prod gel # database client npm install --save-dev @gel/generate # generators ``` -------------------------------- ### Install Gel Client and Generator with yarn Source: https://docs.geldata.com/reference/using/js.md Install the database client and optional generator packages using yarn. ```bash yarn add gel # database client yarn add --dev @gel/generate # generators ``` -------------------------------- ### Clone Gel Examples Repository Source: https://docs.geldata.com/resources/guides/tutorials/graphql_apis_with_strawberry.md Clone the Gel examples repository and navigate to the strawberry-gql directory to begin. ```bash git clone git@github.com:geldata/gel-examples.git cd gel-examples/strawberry-gql ``` -------------------------------- ### Install a Standalone Extension Source: https://docs.geldata.com/reference/datamodel/extensions.md Install standalone extensions like `postgis` using the `gel extension install` command. Ensure to restart your instance afterward. ```bash $ gel extension install postgis Found extension package: postgis version 3.4.3+6b82d77 00:00:03 [====================] 22.49 MiB/22.49 MiB Extension 'postgis' installed successfully. ``` -------------------------------- ### Install @gel/generate with bun Source: https://docs.geldata.com/reference/using/js/generation.md Install the @gel/generate package as a development dependency using bun. ```bash bun add --dev @gel/generate ``` -------------------------------- ### Install Gel Package Source: https://docs.geldata.com/learn/tutorials/gel_drizzle_booknotes.md Installs the Gel library for database access in your project. ```bash npm i gel ``` -------------------------------- ### GraphQL GET Request Example Source: https://docs.geldata.com/reference/using/graphql.md Example of sending a GraphQL query via a GET request with URL-encoded parameters for query, variables, and globals. ```bash $ curl \ -H application/x-www-form-urlencoded \ -X GET http://localhost:10787/branch/main/graphql \ -G \ --data-urlencode 'query=query getMovie($title: String!) { Movie(filter: {title:{eq: $title}}) { id title }}' \ --data-urlencode 'variables={ "title": "The Batman" }' \ --data-urlencode 'globals={ "default::current_user": "04e52807-6835-4eaa-999b-952804ab40a5" }' {"data": {...}} ``` -------------------------------- ### Install Gel Client for Node.js Source: https://docs.geldata.com/learn/clients.md Install the Gel client library for Node.js using npm or yarn. ```bash $ npm install gel # npm $ yarn add gel # yarn ``` -------------------------------- ### Install Gel Client and Generator with pnpm Source: https://docs.geldata.com/reference/using/js.md Install the database client and optional generator packages using pnpm. ```bash pnpm add --save-prod gel # database client pnpm add --save-dev @gel/generate # generators ``` -------------------------------- ### Create Gel Client in Go Source: https://docs.geldata.com/reference/using/clients.md Initialize a Gel client in Go. This example demonstrates setting up the client with options and performing a single query. ```go package main import ( "context" "github.com/geldata/gel-go" "github.com/geldata/gel-go/gelcfg" ) func main() { ctx := context.Background() client, err := gel.CreateClient(gelcfg.Options{}) if err != nil { log.Fatal(err) } defer client.Close() var ( answer int64 ) query := "select 42" err = client.QuerySingle(ctx, query, &answer) } ``` -------------------------------- ### GraphQL GET Request Example Source: https://docs.geldata.com/reference/using/graphql.md An example of how to send a GraphQL query using an HTTP GET request. Query parameters are used for passing the query and variables. ```APIDOC ## GraphQL GET Request Example ### Description Sends a GraphQL query using an HTTP GET request with query parameters. ### Method GET ### Endpoint `http:///branch//graphql` ### Query Parameters - **query** (string) - Required - The GraphQL query string. - **variables** (string) - Optional - A JSON string containing variables for the query. - **globals** (string) - Optional - A JSON string containing global variables (deprecated, use `variables.__globals__` instead). - **operationName** (string) - Optional - The name of the operation to execute. ### Request Example ```bash $ curl \ -H application/x-www-form-urlencoded \ -X GET http://localhost:10787/branch/main/graphql \ -G \ --data-urlencode 'query=query getMovie($title: String!) { Movie(filter: {title:{eq: $title}}) { id title }}' \ --data-urlencode 'variables={ "title": "The Batman" }' \ --data-urlencode 'globals={ "default::current_user": "04e52807-6835-4eaa-999b-952804ab40a5" }' ``` ### Response #### Success Response (200) - **data** (object) - Contains the result of the GraphQL query. ``` -------------------------------- ### Install @gel/generate with deno Source: https://docs.geldata.com/reference/using/js/generation.md Install the @gel/generate package as a development dependency using deno. ```bash deno add --dev npm:@gel/generate ``` -------------------------------- ### Configure Go Environment Source: https://docs.geldata.com/learn/clients.md Initialize a Go module and create a hello.go file. ```bash $ go mod init example/quickstart $ touch hello.go ``` -------------------------------- ### Install Gel Client for Python Source: https://docs.geldata.com/learn/clients.md Install the Gel client library for Python using pip. ```bash $ pip install gel ``` -------------------------------- ### Clone and Set Up FastAPI Project Source: https://docs.geldata.com/learn/quickstart/setup/fastapi.md Clone the FastAPI starter template, navigate into the project directory, create and activate a virtual environment, install dependencies, and initialize the Gel project. ```sh $ git clone \ git@github.com:geldata/quickstart-fastapi.git \ flashcards $ cd flashcards $ python -m venv venv $ source venv/bin/activate # or venv\Scripts\activate on Windows $ pip install -r requirements.txt $ uvx gel project init ``` -------------------------------- ### Fetch Movie by Name Request Example Source: https://docs.geldata.com/resources/guides/tutorials/rest_apis_with_flask.md Example of an HTTP GET request to fetch a movie by its name using the 'filter_name' parameter. ```bash $ httpx -m GET http://localhost:5000/movies \ -p 'filter_name' 'The Avengers' ``` -------------------------------- ### Test Getting All Actors with httpx Source: https://docs.geldata.com/resources/guides/tutorials/rest_apis_with_flask.md Example of using the httpx command-line tool to send a GET request to the /actors endpoint to retrieve all actors. ```bash $ httpx -m GET http://localhost:5000/actors ``` -------------------------------- ### Get PostGIS SVN version Source: https://docs.geldata.com/reference/stdlib/postgis.md Returns the SVN version of the PostGIS installation. ```eql ext::postgis::postgis_svn_version( ) -> optional std::str ``` -------------------------------- ### Initialize a Local Project Interactively via CLI Source: https://docs.geldata.com/cloud/cli.md Run `gel project init` without the `--server-instance` option to be prompted interactively for the Gel Cloud instance name in the format `/`. ```bash $ gel project init ``` -------------------------------- ### Example Version Check Request Source: https://docs.geldata.com/reference/using/cli/network.md This is an example of the HTTP GET request made by the CLI to check for version updates. The User-Agent header is minimal, and platform details are inferred from the URL. ```default GET /archive/.jsonindexes/linux-x86_64.json HTTP/1.1 host: packages.geldata.com content-length: 0 user-agent: gel ``` -------------------------------- ### Navigate and Start Next.js Dev Server Source: https://docs.geldata.com/resources/guides/tutorials/nextjs_pages_router.md After scaffolding, navigate into the project directory and start the development server to view the application locally. ```bash cd nextjs-blog yarn dev ``` -------------------------------- ### Get PostGIS scripts release version Source: https://docs.geldata.com/reference/stdlib/postgis.md Retrieves the release version of the installed PostGIS scripts. ```eql ext::postgis::postgis_scripts_released( ) -> optional std::str ``` -------------------------------- ### Test API with cURL (GET Books) Source: https://docs.geldata.com/learn/tutorials/gel_drizzle_booknotes.md Example cURL command to fetch all books from the API. ```bash curl -X GET http://localhost:3000/api/books ``` -------------------------------- ### Get Default TransactionOptions Source: https://docs.geldata.com/reference/using/python/api/advanced.md Retrieves the default TransactionOptions object. This is useful for understanding or starting with the standard configuration. ```python TransactionOptions.defaults() ``` -------------------------------- ### Query Initial Character Data Source: https://docs.geldata.com/resources/guides/migrations/tips.md Example of querying the Character data after the initial migration to verify the setup. ```edgeql-repl db> select Character {name, class}; { default::Character {name: 'Alice', class: warrior}, default::Character {name: 'Billie', class: scholar}, default::Character {name: 'Cameron', class: rogue}, } ``` -------------------------------- ### Initialize Gel Project Source: https://docs.geldata.com/resources/guides/tutorials/chatgpt_bot.md Initializes a new Gel project in the current directory. Prompts for instance name and version. ```bash npx gel project init No `gel.toml` found in `////docs-chatbot` or above Do you want to initialize a new project? [Y/n] > Y Specify the name of Gel instance to use with this project [default: docs_chatbot]: > docs_chatbot Checking Gel versions... Specify the version of Gel to use with this project [default: 3.2]: > 3.2 ``` -------------------------------- ### Call Standard Library Function (len) Source: https://docs.geldata.com/reference/reference/edgeql/functions.md Example of calling the standard library `len` function to get the length of a string. ```edgeql-repl db> select len('foo'); {3} ``` -------------------------------- ### Initialize Gel Project Source: https://docs.geldata.com/resources/guides/tutorials/rest_apis_with_flask.md Initialize a new Gel project using the 'gel project init' command and follow the prompts to name the Gel instance and configure automatic startup. ```bash gel project init Initializing project... Specify the name of Gel instance to use with this project [default: flask_crud]: > flask_crud Do you want to start instance automatically on login? [y/n] > y Checking Gel versions... ``` -------------------------------- ### Analyze Query Performance Source: https://docs.geldata.com/reference/reference/edgeql/analyze.md Example of using the analyze command in the EdgeQL REPL to get performance metrics for a select query. ```edgeql-repl db> analyze select Hero { ... name, ... secret_identity, ... villains: { ... name, ... nemesis: { ... name ... } ... } ... }; ──────────────────────────────────────── Query ──────────────────────────────────────── analyze select ➊ Hero {name, secret_identity, ➋ villains: {name, ➌ nemesis: {name}}}; ──────────────────────── Coarse-grained Query Plan ──────────────────────── │ Time Cost Loops Rows Width │ Relations ➊ root │ 0.0 69709.48 1.0 0.0 32 │ Hero ╰──➋ .villains │ 0.0 92.9 0.0 0.0 32 │ Villain, Hero.villains ╰──➌ .nemesis │ 0.0 8.18 0.0 0.0 32 │ Hero ``` -------------------------------- ### Get Transaction Datetime Source: https://docs.geldata.com/reference/stdlib/datetime.md Obtain the start time of the current transaction using `datetime_of_transaction()`. This non-volatile function can be used in schema-defined computed properties. ```edgeql std::datetime_of_transaction() -> datetime ``` -------------------------------- ### Start a Gel Instance Source: https://docs.geldata.com/reference/using/cli/gel_instance/gel_instance_start.md Use this command to start a Gel instance. Specify the instance name. The `--foreground` option runs the instance in the foreground, which may require stopping a non-foreground instance first. ```cli gel instance start [--foreground] ``` -------------------------------- ### Get Statement Datetime Source: https://docs.geldata.com/reference/stdlib/datetime.md Retrieve the start time of the current statement using `datetime_of_statement()`. This non-volatile function is suitable for use in schema-defined computed properties. ```edgeql std::datetime_of_statement() -> datetime ``` -------------------------------- ### Connect and Fetch with EdgeDB JavaScript Driver Source: https://docs.geldata.com/resources/changelog/1_0_a2.md Example of connecting to EdgeDB and fetching data using the new JavaScript driver. Ensure you have the driver installed and EdgeDB running. ```javascript const edgedb = require("edgedb"); async function main() { const conn = await edgedb.connect({ user: "edgedb", host: "127.0.0.1", }); try { console.log(await conn.fetchOne("select 1 + 1")); } finally { await conn.close(); } } main(); ``` -------------------------------- ### Initialize a New Gel Project Source: https://docs.geldata.com/reference/using/projects.md Run `gel project init` in your codebase's root directory to set up a new Gel project. It prompts for Gel version and instance name, then links your directory to the specified Gel database instance. ```bash $ gel project init No `gel.toml` found in this repo or above. Do you want to initialize a new project? [Y/n] > Y Checking Gel versions... Specify the version of Gel to use with this project [6.4]: > # left blank for default Specify the name of Gel instance to use with this project: > my_instance Initializing Gel instance... Bootstrap complete. Server is up and running now. Project initialialized. ``` -------------------------------- ### Initialize Gel Client in Go Source: https://docs.geldata.com/learn/clients.md Create a Gel client instance in Go and execute a query. The client automatically connects to the project-linked instance. ```go // hello.go package main import ( "context" "fmt" "log" "github.com/geldata/gel-go" ) func main() { ctx := context.Background() client, err := gel.CreateClient(ctx, gel.Options{}) if err != nil { log.Fatal(err) } defer client.Close() var result float64 err = client. QuerySingle(ctx, "select random();", &result) if err != nil { log.Fatal(err) } fmt.Println(result) } ``` -------------------------------- ### Filter Actors by Name with httpx Source: https://docs.geldata.com/resources/guides/tutorials/rest_apis_with_flask.md Example of using the httpx command-line tool to send a GET request to the /actors endpoint with the 'filter_name' query parameter to retrieve a specific actor. ```bash $ httpx -m GET http://localhost:5000/actors \ -p filter_name "Robert Downey Jr." ``` -------------------------------- ### String Manipulation Functions in EdgeQL Source: https://docs.geldata.com/reference/edgeql/literals.md Provides examples of common string manipulation operations in EdgeQL, including slicing, concatenation, getting the length, trimming whitespace, and splitting strings. ```edgeql select 'hellothere'[5:10]; ``` ```edgeql select 'hello' ++ 'there'; ``` ```edgeql select len('hellothere'); ``` ```edgeql select str_trim(' hello there '); ``` ```edgeql select str_split('hello there', ' '); ``` -------------------------------- ### Initialize Gel Project Source: https://docs.geldata.com/resources/guides/tutorials/graphql_apis_with_strawberry.md Initialize a new Gel project and configure a Gel instance named 'strawberry_crud', opting to start it automatically on login. ```bash gel project init Specify the name of Gel instance to use with this project [default: strawberry_crud]: > strawberry_crud Do you want to start instance automatically on login? [y/n] > y Checking Gel versions... ``` -------------------------------- ### Initialize a Local Project with a Gel Cloud Instance via CLI Source: https://docs.geldata.com/cloud/cli.md Use this command to initialize a local project and link it to a specific Gel Cloud instance. The instance name is provided using the `--server-instance` flag. ```bash $ gel project init \ --server-instance / ``` -------------------------------- ### Execute EdgeQL Query via cURL (GET) Source: https://docs.geldata.com/reference/using/http.md Example of sending an EdgeQL query using cURL with Bearer token authentication. Ensure you replace placeholders with your actual instance details and secret key. ```bash $ curl -G https://:/branch/main/edgeql \ -H "Authorization: Bearer \ --data-urlencode "query=select Person {*};" ``` -------------------------------- ### Find First Occurrence Index in Array Source: https://docs.geldata.com/reference/stdlib/generic.md Use `find()` to get the index of the first occurrence of an element in an array. An optional `from_pos` argument can specify the starting search position. Returns `-1` if not found. ```edgeql-repl db> select find([2, 5, 7, 2, 100], 2); {0} ``` ```edgeql-repl db> select find([2, 5, 7, 2, 100], 2, 1); {3} ``` -------------------------------- ### WebAuthn Client Setup and Event Handling Source: https://docs.geldata.com/reference/auth/webauthn.md Initializes the WebAuthnClient with necessary URLs and sets up event listeners for sign-up and sign-in buttons. Requires the email input to be present. ```javascript import { WebAuthnClient } from "@gel/auth-core/webauthn"; const webAuthnClient = new WebAuthnClient({ signupOptionsUrl: "http://localhost:3000/auth/webauthn/register/options", signupUrl: "http://localhost:3000/auth/webauthn/register", signinOptionsUrl: "http://localhost:3000/auth/webauthn/authenticate/options", signinUrl: "http://localhost:3000/auth/webauthn/authenticate", verifyUrl: "http://localhost:3000/auth/webauthn/verify", }); document.addEventListener("DOMContentReady", () => { const signUpButton = document.querySelector("button#sign-up"); const signInButton = document.querySelector("button#sign-in"); const emailInput = document.querySelector("input#email"); if (signUpButton) { signUpButton.addEventListener("click", async (event) => { event.preventDefault(); const email = emailInput.value.trim(); if (!email) { throw new Error("No email provided"); } try { await webAuthnClient.signUp(email); window.location = "http://localhost:3000/signup-success"; } catch (err) { console.error(err); window.location = "http://localhost:3000/signup-error"; } }); } if (signInButton) { signInButton.addEventListener("click", async (event) => { event.preventDefault(); const email = emailInput.value.trim(); if (!email) { throw new Error("No email provided"); } try { await webAuthnClient.signIn(email); window.location = "http://localhost:3000"; } catch (err) { console.error(err); window.location = "http://localhost:3000/signup-error"; } }) } }); ``` -------------------------------- ### Initialize Gel Project Source: https://docs.geldata.com/resources/guides/tutorials/trpc.md Run this command to initialize a new Gel project and set up a default schema. ```bash pnpm dlx gel project init # or `npx gel project init` ``` -------------------------------- ### EdgeQL Transaction with Savepoint Rollback Example Source: https://docs.geldata.com/reference/reference/edgeql/tx_sp_rollback.md Demonstrates starting a transaction, declaring a savepoint, rolling back to that savepoint, and then committing the transaction. Note that 'rollback to savepoint' implicitly destroys savepoints created after the named one. ```edgeql start transaction; # ... declare savepoint f1; # ... rollback to savepoint f1; # ... rollback; ``` -------------------------------- ### Start Development Server Source: https://docs.geldata.com/resources/guides/contributing/code.md Starts the Gel development server using the `edb server` command. This server can then be connected to using the `gel` REPL or language bindings. ```bash $ edb server ``` -------------------------------- ### Find First Occurrence Index in String or Bytes Source: https://docs.geldata.com/reference/stdlib/generic.md Use `find()` to get the starting index of the first occurrence of a substring or byte sequence within a larger string or byte sequence. Returns `-1` if not found. ```edgeql-repl db> select find('qwerty', 'we'); {1} ``` ```edgeql-repl db> select find(b'qwerty', b'42'); {-1} ``` -------------------------------- ### JSON Credentials File Example Source: https://docs.geldata.com/learn/clients.md Use a JSON file to store connection details like host, port, user, password, branch, and TLS certificate data. This is useful for local development and Docker setups. ```json { "host": "localhost", "port": 10700, "user": "testuser", "password": "testpassword", "branch": "main", "tls_cert_data": "-----BEGIN CERTIFICATE-----\nabcdef..." } ``` -------------------------------- ### View Gel Instance CLI Help Source: https://docs.geldata.com/learn/instances.md Access the help text for the `gel instance` command to find more options and details on managing instances. ```bash $ gel instance --help ``` -------------------------------- ### Initialize a Gel Project Source: https://docs.geldata.com/learn/clients.md Create a new directory and initialize a Gel project. This is the first step before configuring the environment and installing client libraries. ```bash $ mydir myproject $ cd myproject $ gel project init ``` -------------------------------- ### Initialize Gel Project Source: https://docs.geldata.com/resources/guides/tutorials/nextjs_app_router.md Run this command in your project's root directory to initialize a new Gel project. It will prompt for instance name and version, then set up the necessary configuration files. ```bash $ npx gel project init No `gel.toml` found in `~/nextjs-blog` or above Do you want to initialize a new project? [Y/n] > Y Specify the name of Gel instance to use with this project [default: nextjs_blog]: > nextjs_blog Checking Gel versions... Specify the version of Gel to use with this project [default: x.x]: > ┌─────────────────────┬──────────────────────────────────────────────┐ │ Project directory │ ~/nextjs-blog │ │ Project config │ ~/nextjs-blog/gel.toml │ │ Schema dir (empty) │ ~/nextjs-blog/dbschema │ │ Installation method │ portable package │ │ Start configuration │ manual │ │ Version │ x.x │ │ Instance name │ nextjs_blog │ └─────────────────────┴──────────────────────────────────────────────┘ Initializing Gel instance... Applying migrations... Everything is up to date. Revision initial. Project initialized. ``` -------------------------------- ### Start Migration with Desired Schema Source: https://docs.geldata.com/resources/guides/migrations/guide.md Starts a migration by providing the target schema within a `start migration to {}` block. ```edgeql-repl db> start migration to { ... module default { ... type User { ... nam: str; ... } ... } ... }; ``` -------------------------------- ### Clone and Initialize Next.js Project Source: https://docs.geldata.com/learn/quickstart/setup/nextjs Clone the Gel Next.js starter template and install dependencies. Then, initialize your local Gel project. ```bash git clone \ git@github.com:geldata/quickstart-nextjs.git \ flashcards $ cd flashcards $ npm install $ npx gel project init ``` -------------------------------- ### Install Geldata CLI with Powershell Source: https://docs.geldata.com/learn/installation.md Use this command to install the Geldata CLI globally using a Powershell script. Ensure you have Powershell installed. ```powershell PS> irm https://www.geldata.com/ps1 | iex ``` -------------------------------- ### Example: Set Module Source: https://docs.geldata.com/reference/reference/edgeql/sess_set_alias.md Demonstrates setting the default module for the current session. ```edgeql set module foo; ``` -------------------------------- ### Install Geldata CLI with Bash Source: https://docs.geldata.com/learn/installation.md Use this command to install the Geldata CLI globally using a bash script. Ensure you have curl installed. ```bash $ curl https://www.geldata.com/sh --proto "=https" -sSf1 | sh ``` -------------------------------- ### Create Project Directory Source: https://docs.geldata.com/resources/guides/tutorials/rest_apis_with_fastapi.md Create a new directory for your project and navigate into it. ```bash mkdir fastapi-crud cd fastapi-crud ``` -------------------------------- ### Install EdgeDB 4 on Debian/Ubuntu Source: https://docs.geldata.com/resources/changelog/4_x.md Install EdgeDB v4 on Debian/Ubuntu systems after configuring the APT repository. This command updates package lists and installs the server. ```bash $ sudo apt-get update && sudo apt-get install edgedb-4 ``` -------------------------------- ### Start Next.js Development Server Source: https://docs.geldata.com/resources/guides/tutorials/nextjs_app_router.md Navigate to your project directory and start the Next.js development server using npm, yarn, pnpm, or bun. ```bash cd nextjs-blog npm dev # or yarn dev or pnpm dev or bun run dev ``` -------------------------------- ### Install Gel v7 on CentOS/RHEL Source: https://docs.geldata.com/resources/changelog/7_x.md Install Gel v7 on CentOS/RHEL systems using the yum package manager. This command directly installs the server package. ```bash $ sudo yum install gel-7 ``` -------------------------------- ### Install Gel AI Package Source: https://docs.geldata.com/reference/ai/python.md Install the Gel AI package using pip. This command installs the AI extension along with the core Gel library. ```bash $ pip install 'gel[ai]' ``` -------------------------------- ### Configure Python Environment Source: https://docs.geldata.com/learn/clients.md Set up a Python virtual environment and create a main.py file. ```bash $ python -m venv venv $ source venv/bin/activate $ touch main.py ``` -------------------------------- ### Install Gel CLI on Linux or macOS Source: https://docs.geldata.com/learn/cli.md Installs the Gel CLI using a curl script. Ensure you have `curl` installed and that your shell supports `https` and TLS 1.2. ```bash $ curl --proto '=https' --tlsv1.2 -sSf https://www.geldata.com/sh | sh ``` -------------------------------- ### Install Drizzle ORM Source: https://docs.geldata.com/learn/guides/drizzle Install the Drizzle ORM package for your project. ```bash npm install drizzle-orm ``` -------------------------------- ### Initialize a New Gel Project Source: https://docs.geldata.com/learn/projects.md This interactive command initializes a new Gel project, prompts for instance and version details, and creates necessary configuration files. ```bash $ gel project init No `gel.toml` found in this repo or above. Do you want to initialize a new project? [Y/n] > Y Specify the name of Gel instance to use with this project [default: my_instance]: > my_instance Checking Gel versions... Specify the version of Gel to use with this project [default: x.x]: > # (left blank for default) ... Successfully installed x.x+cc4f3b5 Initializing Gel instance... Applying migrations... Everything is up to date. Revision initial Project initialized. To connect to my_instance, run `gel` ``` -------------------------------- ### Initialize Next.js Project Source: https://docs.geldata.com/learn/tutorials/gel_drizzle_booknotes.md Creates a new Next.js application with specified configurations. Ensure Node.js and npm are installed. ```bash npx create-next-app@latest book-notes-app # When prompted, choose: # ✔ Would you like to use TypeScript? Yes # ✔ Would you like to use ESLint? Yes # ✔ Would you like to use Tailwind CSS? Yes # ✔ Would you like to use `src/` directory? Yes # ✔ Would you like to use App Router? Yes # ✔ Would you like to use Turbopack for `next dev`? No # ✔ Would you like to customize the default import alias (@/*)? No cd book-notes-app ``` -------------------------------- ### Install Gel Generate Dev Dependency Source: https://docs.geldata.com/reference/using/js/interfaces.md Install `@gel/generate` as a dev dependency. ```bash $ npm install @gel/generate --save-dev # npm users $ yarn add @gel/generate --dev # yarn users $ pnpm add --dev @gel/generate # pnpm users $ bun add --dev @gel/generate # bun users $ deno add --dev npm:@gel/generate # deno users ``` -------------------------------- ### Install Gel Package (CentOS/RHEL) Source: https://docs.geldata.com/reference/running/deployment/bare_metal.md Install the Gel package using YUM. ```bash sudo yum install gel-6 ``` -------------------------------- ### Initialize a Cloud instance with a specific server version Source: https://docs.geldata.com/reference/using/cli/gel_project/gel_project_init.md This command initializes a project and specifies the latest release within the 6.x major version. ```bash gel project init --server-version 6.1 ``` -------------------------------- ### Initialize Gel Client in Python Source: https://docs.geldata.com/learn/clients.md Create a Gel client instance in Python and execute a simple query. The client automatically connects to the project-linked instance. ```python from gel import create_client client = create_client() result = client.query_single("select random()") print(result) ``` -------------------------------- ### std::bigint Encoding Example Source: https://docs.geldata.com/resources/protocol/dataformats.md Example encoding for the bigint value -15000. ```c // ndigits 0x00 0x02 // weight 0x00 0x01 // sign 0x40 0x00 // reserved 0x00 0x00 // digits 0x00 0x01 0x13 0x88 ``` -------------------------------- ### Install Gel Client for .NET Source: https://docs.geldata.com/learn/clients.md Add the Gel.Net.Driver package to your .NET project. ```bash $ dotnet add package Gel.Net.Driver ``` -------------------------------- ### EdgeQL REPL Example Source: https://docs.geldata.com/resources/guides/contributing/documentation.md Use `edgeql-repl` for EdgeQL interactive examples, including prompts and optional output. The copy button excludes the prompt and output. ```default .. code-block:: edgeql-repl db> insert Person { name := $name }; Parameter $name: Pat {default::Person {id: e9009b00-8d4e-11ed-a556-c7b5bdd6cf7a}} ``` ```edgeql-repl db> insert Person { name := $name }; Parameter $name: Pat {default::Person {id: e9009b00-8d4e-11ed-a556-c7b5bdd6cf7a}} ``` -------------------------------- ### JavaScript Query Example Source: https://docs.geldata.com/resources/guides/contributing/documentation.md Example of executing a query using the JavaScript client. ```default .. code-block:: javascript await client.query("select 'I ❤️ " ++ $name ++ "!';", { name: "rock and roll" }); ``` ```javascript await client.query("select 'I ❤️ " ++ $name ++ "!';", { name: "rock and roll" }); ``` -------------------------------- ### Gel Project Configuration Example Source: https://docs.geldata.com/reference/using/projects.md This TOML snippet shows a typical configuration for a Gel project, including server version, schema directory, and command hooks for project initialization and schema updates. ```toml [instance] server-version = "6.0" [project] schema-dir = "db/schema" [hooks] project.init.after = "setup_dsn.sh" branch.switch.after = "setup_dsn.sh" schema.update.after = "gel-orm sqlalchemy --mod compat --out compat" [[watch]] files = ["queries/*.edgeql"] script = "npx @edgedb/generate queries" ``` -------------------------------- ### Enable and Start Gel Systemd Unit Source: https://docs.geldata.com/reference/running/deployment/bare_metal.md Enable the Gel systemd service to start automatically on boot and start it immediately. This configures the server to listen on port 5656 with data stored in /var/lib/gel/6/data. ```bash sudo systemctl enable --now gel-server-6 ``` -------------------------------- ### Install Gel Package Source: https://docs.geldata.com/reference/using/js/interfaces.md Install the `gel` package using your preferred package manager. ```bash $ npm install gel # npm users $ yarn add gel # yarn users $ pnpm add gel # pnpm users $ bun add gel # bun users $ deno add npm:gel # deno users ``` -------------------------------- ### Initialize Project with Gel v7 Source: https://docs.geldata.com/resources/changelog/7_x.md Specify version 7.0 when initializing a new project to use the latest features. Pre-release versions are not stable. ```bash $ gel project init --server-version 7.0 ``` -------------------------------- ### Install @gel/generate with pnpm Source: https://docs.geldata.com/reference/using/js/generation.md Install the @gel/generate package as a development dependency using pnpm. ```bash pnpm add --save-dev @gel/generate ```