Socket
Book a DemoInstallSign in
Socket

@terminusdb/terminusdb-client

Package Overview
Dependencies
Maintainers
3
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@terminusdb/terminusdb-client

TerminusDB client library

Source
npmnpm
Version
4.2.1
Version published
Weekly downloads
245
21.89%
Maintainers
3
Weekly downloads
 
Created
Source

TerminusDB-Client

build status Coverage Status

Promise based terminus client for the browser and node.js

Requirements

Installation

TerminusDB Client can be used as either a Node.js module available through the npm registry, or directly included in web-sites by including the script tag below.

NPM Module

Before installing, download and install Node.js. Node.js 0.10 or higher is required.

Installation is done using the npm install command:

Using npm:

$ npm install --save @terminusdb/terminusdb-client

Minified Script

Using cdn:

<script src="https://unpkg.com/@terminusdb/terminusdb-client/dist/terminusdb-client.min.js"></script>

Downloading:

Download the terminusdb-client.min.js file from the /dist directory and save it to your location of choice, then:

<script src="http://my.saved.location/terminusdb-client.min.js"></script>

Usage

This example creates a simple Express.js server that will post an account to a database with the id "banker" and the default "admin" user with password "root" For the full Documentation

const express = require("express");
const app = express();
const port = 3000;

const TerminusClient = require("@terminusdb/terminusdb-client");

// Connect and configure the TerminusClient
const client = new TerminusClient.WOQLClient("https://127.0.0.1:6363/", {
  db: "banker",
  user: "admin",
  key: "root",
});
//to change the starting settings
client.db("banker");
client.organization("admin");

async function postAccount() {
  try {
    const WOQL = TerminusClient.WOQL;
    const query = WOQL.using("admin/banker").and(
      WOQL.add_triple("doc:smog", "type", "scm:BankAccount"),
      WOQL.add_triple("doc:smog", "owner", "smog"),
      WOQL.add_triple("doc:smog", "balance", 999)
    );
    await client.connect();
    client
      .query(query, "adding smog's bank account")
      .then((response) => {
        return response;
      })
      .catch((err) => {
        console.log("error", err);
      });
  } catch (err) {
    console.error(err);
  }
}

app.post("/account", (req, res) => {
  postAccount().then((dbres) => res.send(JSON.stringify(dbres)));
});

app.listen(port, () => {
  console.log(`Backend Server listening at http://localhost:${port}`);
  client
    .connect()
    .then(function (response) {
      // handle success
      console.log(response);
    })
    .catch(function (error) {
      // handle error
      console.log(error);
    });
});

Options

connections options.

To initialize TerminusDB client with custom options use

const TerminusClient = require("@terminusdb/terminusdb-client");

const client = new TerminusClient.WOQLClient("https://127.0.0.1:6363/", {
  db: "test_db",
  user: "admin",
  key: "my_secret_key",
});

API

The API is documented at: https://terminusdb.com/docs/reference/js-client/core/#terminusdb-client-api

Report Issues

If you have encounter any issues, please report it with your os and environment setup, version that you are using and a simple reproducible case.

If you encounter other questions, you can ask in our community forum or Slack channel.

Contribute

It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.

Please check Contributing.md for more information.

Licence

The APACHE 2.0 License

Copyright (c) 2019

Keywords

Terminus

FAQs

Package last updated on 25 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts