Package Exports
- @terminusdb/terminusdb-client
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@terminusdb/terminusdb-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
TerminusDB-Client
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-clientMinified 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