Skip to content

Latest commit

 

History

History
123 lines (78 loc) · 3.66 KB

readme.md

File metadata and controls

123 lines (78 loc) · 3.66 KB

EdgeDB Deno driver

deno land Build Status Join GitHub discussions

edgedb-deno is the official EdgeDB driver for Deno. 🦕

This repo is automatically generated from the source of the edgedb-js driver. For documentation, issues, or details about the development of edgedb-deno, please refer to the edgedb-js repo.

Import

import * as edgedb from "https://deno.land/x/edgedb/mod.ts";

Following Deno convention it is recommended to always import a specific tagged version of edgedb-deno, and to not import from the underscored /_src path (all of edgedb-deno's public API is exported from the /mod.ts file).

The main branch of this repo mirrors the latest commits to the master branch of edgedb-js, though it not recommended to import from this branch directly, as it may contain breaking changes.

Quick start

First install EdgeDB, then create and start an EdgeDB instance. The quickstart guide in the EdgeDB docs is a good place to get started: https://www.edgedb.com/docs/guides/quickstart

Now you're ready to import edgedb-deno and start querying your database:

import * as edgedb from "https://deno.land/x/edgedb/mod.ts";

const client = edgedb.createClient();

console.log(await client.querySingle("SELECT 1 + <int64>$num", { num: 2 }));

await client.close();

For the full documentation see the edgedb-js docs.

Permissions

The permissions edgedb-deno may require are detailed below:

--allow-net (required)

This permission is required to connect to EdgeDB instances.

--unstable flag (required < v1.35.1)

edgedb-deno uses the recently stabilized alpnProtocols API on Deno.connectTls. If you are running an older version of Deno, you may need to enable this flag

--allow-env (optional)

Needed if connecting with an instance name, to get your home directory (where the .edgedb directory is located).

--allow-read (optional)

Needed if connecting with an instance name, to read the instance credentials file from <home-dir>/.edgedb/credentials.

--unsafely-ignore-certificates-error (optional)

Needed if connecting to an instance that is using self-signed certificates, which is the case if running the server in insecure_dev_mode or with EDGEDB_SERVER_TLS_CERT_MODE=generate_self_signed.

Generating typed queries, interfaces and the QueryBuilder

Follow the up to date guide here

Prerequisites

  1. Create the file importMap.json in the root of your Deno project with the following content:
{
  "imports": {
    "edgedb": "https://deno.land/x/edgedb/mod.ts",
    "edgedb/": "https://deno.land/x/edgedb/"
  }
}
  1. Create the file deno.json with the following content:
{
  "importMap": "./importMap.json"
}

Generating the QueryBuilder

deno run --allow-all --unstable https://deno.land/x/edgedb/generate.ts edgeql-js

Generating typed queries

deno run --allow-all --unstable https://deno.land/x/edgedb/generate.ts queries

Generating interfaces

deno run --allow-all --unstable https://deno.land/x/edgedb/generate.ts interfaces