TerminusDB Quickstart Tutorial
Complete this tutorial to get TerminusDB running and create your first database. Check off each step as you complete it!
TerminusDB runs in Docker for easy installation and portability. If you don't have Docker installed:
- Download Docker Desktop from docker.com
- Install and start Docker Desktop
- Verify installation by running:
docker --version
Run this command to download and start TerminusDB:
docker run --pull always -d -p 127.0.0.1:6363:6363 -v terminusdb_storage:/app/terminusdb/storage --name terminusdb terminusdb/terminusdb-server:v12This command:
- Downloads the latest TerminusDB image
- Starts a container named
terminusdb - Opens port 6363 for the API
- Creates a persistent volume
terminusdb_storagefor your data
Navigate to the DFRNT Modeller in your browser:
You should see the DFRNT welcome screen. Sign up or login and create your account.
Install the TerminusDB JavaScript client:
npm install @terminusdb/terminusdb-clientCreate a connection to your local TerminusDB instance. Create a main.js file and run it with node main.js.
import TerminusClient from "@terminusdb/terminusdb-client";
import {WOQL} from "@terminusdb/terminusdb-client";
const client = new TerminusClient.WOQLClient("http://127.0.0.1:6363", {
user: "admin",
organization: "admin"
});
// Connect and verify
client.connect({ key: "root", db: "my_first_db" }).then(() => {
console.log("Connected to TerminusDB!");
});Create a new database using the client:
await client.createDatabase("my_first_db", {
label: "My First Database",
comment: "A tutorial database"
});
console.log("Database created successfully!");Define a simple schema for storing person records:
const schema = {
"@type": "Class",
"@id": "Person",
name: "xsd:string",
age: "xsd:integer",
email: "xsd:string"
};
await client.addDocument(schema, { graph_type: "schema" });Remember to remove the database creation part from as the database is already created.
Add a person document to your database:
const person = {
"@id": "Person/Alice",
"@type": "Person",
name: "Alice Johnson",
age: 30,
email: "alice@example.com"
};
await client.addDocument(person);
console.log("Document inserted!");Retrieve all person documents:
const person = await client.getDocument({ type: "Person" });
console.log("People in database:", person);const docs = await client.query(WOQL.read_document("Person/Alice", "v:doc"));
console.log("Alice:", docs.bindings);Next Steps
Congratulations! You've completed the quickstart tutorial. Here's what to explore next:
- Learn about Documents & Schema
- Query with GraphQL
- Connect with JavaScript Client
- Connect with Python Client
Managing Your Container
Stop TerminusDB:
docker stop terminusdbRestart TerminusDB:
docker restart terminusdbView logs:
docker logs terminusdbYour data persists in the terminusdb_storage volume, so it's safe to stop and restart the container.