TriCoreDB for Node.js
0.1.1The official JavaScript / TypeScript client: SQL, documents, cache, vectors and graphs over one native connection.
Install
npm
npm install tricoredbRequirements
- Node.js 18 or later
- A TriCoreDB server, 0.1.0-rc.1 or later (install one)
Highlights
- Zero runtime dependencies
- Written in TypeScript, types included
- ESM and CommonJS
- Transactions, connection pool, TLS and mutual TLS
Quick start
index.mjs
import { TriCore } from 'tricoredb';
const db = await TriCore.connect({
host: '127.0.0.1',
port: 8427,
user: process.env.TRICOREDB_USER,
secret: process.env.TRICOREDB_PASSWORD,
});
await db.execute('CREATE TABLE IF NOT EXISTS users (id INT PRIMARY KEY, name TEXT)');
await db.execute('INSERT INTO users VALUES (?, ?)', [1, 'Ada']);
const rows = await db.query('SELECT id, name FROM users WHERE id = ?', [1]);
console.log(rows.dicts()); // [ { id: '1', name: 'Ada' } ]
await db.close();TLS
This example connects without TLS, which matches the development container. The default image requires TLS. The README shows how to connect with a CA certificate, and documents every call.