JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 35
  • Score
    100M100P100Q61322F
  • License Apache-2.0

TypeDB HTTP Driver

Package Exports

  • @samuel-butcher-typedb/typedb-http-driver

Readme

TypeDB HTTP Typescript Driver

Driver Architecture

To learn about how the TypeDB HTTP driver communicates with the TypeDB Server, refer to the HTTP API Reference.

API Reference

To learn about the methods available for executing queries and retrieving their answers using Typescript, refer to the API Reference.

Install TypeDB HTTP Typescript Driver through NPM

  1. Install typedb-driver-http through npm:
npm install typedb-driver-http
  1. Make sure the TypeDB Server is running.
  2. Use TypeDB Driver in your program:
import { TypeDBHttpDriver, isApiErrorResponse } from "typedb-driver-http";

const driver = new TypeDBHttpDriver({
    username: "admin",
    password: "password",
    addresses: [ "localhost:1729" ],
});

const transactionResponse = await driver.openTransaction("database-name", "read");
if (isApiErrorResponse(transactionResponse)) throw transactionResponse.err;
const transactionId = transactionResponse.ok.transactionId;

const answerResponse = await driver.query(transactionId, "match entity $x;");
if (isApiErrorResponse(answerResponse)) throw answerResponse.err;
const answer = answerResponse.ok;

if (answer.answerType === "conceptRows") {
   answer.answers.forEach((row) => {
        console.log(row.data)
    })
}