Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
How to connect to an existing database using the TerminusDB JavaScript Client
Assuming you have connected with the JavaScript Client, connecting to a database is the same for TerminusDB and TerminusCMS.
The example code below registers your database in woqlClient parameters and then all your calls will be made to this db -
How-to add documents to TerminusDB and TerminusCMS using the JavaScript Client
After you have imported the terminusdb_client
, and created a client, connected to a database, and added some schema, you can then use this client to insert a document that conforms to the schema.
Add documents to the schema using addDocument
:
How-to update a document in TerminusDB and TerminusCMS using the JavaScript Client
To update documents in your database, you first need to you want to change. You then need to make your changes and update it. This example shows how -
How to connect to TerminusDB and TerminusCMS using the JavaScript Client
Ensure you have installed the JavaScript Client. See here for installation instructions
Depending on whether you are connecting to an instance you have set up yourself, or whether you are using TerminusCMS in the cloud, there are two different methods of connection.
In both cases, you should load the TerminusDB client in your script with the following:
The TerminusCMS endpoint has the form https://cloud.terminusdb.com/TEAM/ where TEAM is the name of the team you are using in TerminusCMS for the data products you want to access. In order to connect to this team, you will need to get your API key after selecting the team you want to use. To create a client use the following code within your script, ensuring to use your credentials.
Whether you are connecting to a local docker, a local server, or a server that you've set up somewhere, you can use the following to log in to TerminusDB.
Try out the Getting Started with the TerminusDB JavaScript Client five-part tutorial to get to grips with it.
How-to delete a document in TerminusDB and TerminusCMS using the JavaScript Client
In order to delete a document you need to know the document id.
Add a schema to TerminusDB and TerminusCMS using the TerminusDB JavaScript Client
A very quick tutorial combining the individual elements of the JavaScript how-to guides to get you started.
Common uses of a WOQLClient include connecting to an existing database and creating a new database.
Connect to an existing database using the example below.
Create a new database using the example below.
Create a schema
Add a schema
Add documents
Get documents
Query documents
Data: Player roster
Code: Create a schema
Create a schema object with properties name
and position
. The object is uniquely identified by name
.
Code: Add a schema
Add the schema object to the database.
Add the schema object to a document using addDocument
which returns a Promise.
Code: Add documents
Once a schema is added, add documents corresponding to the schema.
Add documents to the schema using addDocument
which returns a Promise.
Code: Get documents
Get a list of documents or specific documents added to the schema
Get a list of documents using getDocument
as_list
. Results, stored in document
, are shown further below.
Code: Query documents
Get a list of documents that matches the query
Get a list of documents using getDocument
as_list
. Results, stored in document
, are shown further below.
Code: Query documents using WOQL
Query documents using Web Object Query Language (WOQL) to get the same result given by the above example. You can find more about WOQL here.
Get documents using using WOQL.triple()
to create a WOQL query then execute that query using client.query()
. Results, stored in results
, are shown further below
The following code segments demonstrate creating relationships or links between documents
Code: Create schema for team
The Team
object is uniquely identified by the property name
. The players
property consists of a set of Player
classes that create a link between theTeam
and Player
schema.
Code: Add a schema
Add the schema object to the database.
Add the schema object to a document using addDocument
that returns a Promise.
Code: Add documents
Add documents corresponding to the Team
schema.
Code: Get all of the teams
Get a list of Team
documents.
After you have imported the terminusdb_client
, and , and you can create a schema.
This guide demonstrates the basic use of the WOQLClient library to connect to TerminusDB with the JavaScript Client. Refer to for detailed documentation.
The code discussed on this page is also available in full on GitHub -
You can also find a comprehensive getting-started guide on GitHub: .
Create a schema and add documents to the schema by using the document interface. Refer to the for more detail. After creating or connecting to a database, create a schema to add and retrieve data. A simple player roster is used as an example. Using Player roster data, the steps below are demonstrated.
How-to get documents to TerminusDB and TerminusCMS using the JavaScript Client
How-to create a database using the TerminusDB JavaScript Client
To create a database with an already connected client, you can write:
After the database is created the client will be connected to it.
Try out the Getting Started with the TerminusDB JavaScript Client five-part tutorial to get to grips with it.