npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@terminusdb/terminusdb-client

v10.0.33

Published

TerminusDB client library

Downloads

287

Readme

TerminusDB JavaScript Client


Discord Reddit Twitter

npm version npm downloads

This repository is for the JavaScript client library for TerminusDB and TerminusCMS.

TerminusDB is an open-source graph database and document store. It allows you to link JSON documents in a powerful knowledge graph all through a simple document API.

TerminusCMS is a headless content management system for complex enviroments. Try it out for yourself, it's free to get started with generous limits. Clone a demo project to play around. Sign up.

Requirements

  • Node.js version 10+ if using the TerminusDB client library as a Node.js package

Installation

The TerminusDB JavaScript client library can be used either as a Node.js package or as a script that runs in the browser.

NPM Package

:memo: If you don't already have Node.js installed, install it first.

To install the terminusdb-client package as a dependency in an existing package, run:

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

This command updates your package.json.

Script

To use the terminusdb-client script on a webpage sourced from a CDN, add this to your HTML:

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

Alternatively, you can download the latest terminusdb-client.min.js, add it to your sources, and use that in the <script> instead.

Usage

This example creates a simple dataProduct, starting to create a database model the schema and insert a simple document

For the full Documentation

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

// Connect and configure the TerminusClient
const client = new TerminusClient.WOQLClient('SERVER_CLOUD_URL/mycloudTeam',
                       {user:"[email protected]", organization:'mycloudTeam'})
                                            
client.setApiKey(MY_ACCESS_TOKEN)

const bankerSchema = [
   {
      "@type":"Class",
      "@id":"BankAccount",
      "@key":{
         "@type":"Hash",
         "@fields":[
            "account_id"
         ]
      },
      "account_id":"xsd:string",
      "owner":"Person",
      "balance":"xsd:decimal"
   },
   {
      "@type":"Class",
      "@id":"Person",
      "@key":{
         "@type":"Lexical",
         "@fields":[
            "name"
         ]
      },
      "name":"xsd:string"
   }
]
 
async function createDataProduct(){
    try{

        await client.createDatabase("banker", {label: "Banker Account", 
                                              comment: "Testing", schema: true})
        //add the schema documents
        await client.addDocument(bankerSchema,{"graph_type":"schema"},null,"add new schema") 
    
        const accountObj = {"@type":"BankAccount",
                            "account_id":"DBZDFGET23456",
                            "owner":{
                                "@type":"Person",
                                "name":"Tom"
                            },
                            "balance":1000
                          }

        //add a document instance
        await client.addDocument(accountObj)

        client.getDocument({"as_list":true,id:'Person/Tom'})

    }catch(err){
        console.error(err.message)
    }
  }

Options

connections options.

To initialize TerminusDB client with custom options use

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

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

API

The TerminusDB API can be found at the TerminusDB Documentation.

Report Issues

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

If you encounter other questions, you can ask them on our Discord Server.

Contribute

:memo: This project uses Husky which automatically runs lint, tests, and other scripts when you try to commit any changes to the repository. This helps us to improve each commit done to the repo and is automatically installed and configured when you do npm install

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