Skip to content
github-actions[bot] edited this page Sep 28, 2026 · 25 revisions

Navigation: Home > SDKs > Client

ThemisDB JavaScript/TypeScript SDK

Official JavaScript/TypeScript client for ThemisDB - A high-performance multi-model database.

Features

  • βœ… TypeScript Support - Full type definitions included
  • βœ… Transaction Support - BEGIN/COMMIT/ROLLBACK with isolation levels
  • βœ… LLM Integration - Native support for LLM interactions (v1.4.0+) πŸ†•
  • βœ… Multi-Model - Relational, Graph, Vector operations
  • βœ… Query Support - AQL (Advanced Query Language)
  • βœ… Topology-Aware - Automatic shard routing
  • βœ… Batch Operations - Efficient bulk operations
  • βœ… Vector Search - Similarity search
  • βœ… Retry Logic - Automatic retries

Installation

npm install @themisdb/client

Quick Start

import { ThemisClient } from "@themisdb/client";

const client = new ThemisClient({
  endpoints: ["http://localhost:8080"],
});

// Basic CRUD
await client.put("relational", "users", "user1", { name: "Alice" });
const user = await client.get("relational", "users", "user1");

// Transactions (NEW!)
const tx = await client.beginTransaction();
try {
  await tx.put("relational", "accounts", "acc1", { balance: 1000 });
  await tx.put("relational", "accounts", "acc2", { balance: 500 });
  await tx.commit();
} catch (error) {
  await tx.rollback();
}

API Reference

LLM Integration (v1.4.0+) πŸ†•

// Create LLM interaction
const result = await client.llmInteraction(
  "gpt-4o",
  [{ role: "user", content: "Explain MVCC" }],
  {
    reasoning_steps: [
      {
        type: "chain_of_thought",
        content: ["MVCC allows parallel reads", "Each tx gets a snapshot"]
      }
    ],
    metadata: { use_case: "docs" }
  }
);

// Get interaction
const interaction = await client.getLlmInteraction(result.id);

// List interactions
const interactions = await client.listLlmInteractions({
  model: "gpt-4o",
  limit: 50,
  offset: 0
});

Transaction Support

// Begin transaction with isolation level
// WARNING: SNAPSHOT isolation allows write-skew and phantom reads.
// Use SERIALIZABLE to prevent these anomalies at the cost of more aborts.
const tx = await client.beginTransaction({ 
  isolationLevel: "SNAPSHOT" // or "READ_COMMITTED" | "SERIALIZABLE"
});

// Operations within transaction
await tx.get("relational", "users", "user1");
await tx.put("relational", "users", "user1", data);
await tx.delete("relational", "users", "user1");
await tx.query("FOR doc IN users RETURN doc");

// Commit or rollback
await tx.commit();
await tx.rollback();

// Check transaction state
console.log(tx.isActive); // true/false
console.log(tx.transactionId); // "txn_123..."

Development

Script Purpose
npm run build Compile TypeScript to dist/
npm run lint Run ESLint
npm run test Run Vitest tests

License

Apache-2.0


ThemisDB 1.9.0-beta Β· Home Β· Module-Index Β· GitHub Β· Issues

ThemisDB Wiki

🏠 Overview

πŸ“š Compendium

πŸš€ Getting Started

πŸ“– Tutorials

πŸ“— User Guide

βš™οΈ Operations & Security

πŸ“Ÿ Ops Runbooks

πŸ—οΈ Architecture

πŸ“ ADRs

πŸ”§ Contributing

πŸ“‹ Governance

πŸ” Audit

🧩 Plugins

πŸ”Œ Adapters

πŸ’‘ Examples

πŸ“¦ Client SDKs

πŸŽ“ Training

πŸ› οΈ Tools

πŸ€– Developer LLM Wiki

Clone this wiki locally