๐ฆ Node.js Client
Welcome to the official ZTeraDB Node.js Client documentation. This package implements a performance-optimized, ZQL-first database driver utilizing a raw TCP socket transport layer.
๐ What Is ZTeraDB?โ
ZTeraDB allows you to connect to your existing databases (PostgreSQL, MySQL, MSSQL, etc.) through a single, unified platform using One Unified Query Language (ZQL).
Technical Overviewโ
This package implements a performance-optimized, ZQL-first Node.js client utilizing a raw TCP socket transport layer.
To ensure low-overhead binary framing, the client communicates with the ZTeraDB server using 4-byte big-endian length-prefixed payloads containing structured JSON data. This underlying transport architecture eliminates HTTP overhead, offering high-throughput query execution directly from your Node.js runtime.
๐ง Architecture Overviewโ
You never connect to your backend databases directly. ZTeraDB handles all connections, cryptographic signing, proxy routing, and query execution securely behind the scenes.
โญ Key Featuresโ
- ๐ Unified Query Language (ZQL): Write once, run on any database.
- ๐ Easy Integration: Seamlessly plugs into any Node.js application.
- โ๏ธ Auto-Managed Connections: Handles connection pooling and automatic retries out of the box.
- ๐ Secure Authentication: Protected via client, access, and secret keys.
- ๐ฏ Clean Query Builder: Fluent, Promise-based interface for standard CRUD operations (
insert,select,update,delete). - ๐ Advanced Filtering: Built-in support for complex logical and mathematical filters.
- ๐งต Streamed Results: Efficiently memory-manages large datasets using Node.js Streams and Async Generators.
- ๐ฆ Modern Ecosystem: npm and Yarn-ready, with first-class support for TypeScript and frameworks like Express, NestJS, and Fastify.
๐ Prerequisites & Requirementsโ
| Requirement | Specification |
|---|---|
| Node.js Version | Node.js 18.20.7 or higher (Download from nodejs.org) |
| Knowledge Base | Familiarity with asynchronous JavaScript (Promises / Async-Await) |
| Credentials | ZTeraDB account with active clientKeys |
Installationโ
Option 1: Via npm (Recommended)โ
Run the following command in your terminal to install the ZTeraDB client:
npm install @zteradb/client
Option 2: Via Yarnโ
Alternatively, you can pull the package using yarn:
yarn add @zteradb/client
๐งช Running Testsโ
To verify that your installation is working correctly and the client can communicate with your environment, you can run the test suite.
- Configure Environment Variables
Create a
.envfile in your root directory (or export them to your environment):
ZTERADB_HOST=localhost
ZTERADB_PORT=7777
ZTERADB_CONFIG=your_config_string_here
- Run the Test Scripts Execute the test suite using your preferred package manager:
# Using npm
npm test
# Using yarn
yarn test
๐ 60-Second Quick Start
import { ZTeraDBConnect, ZTeraDBQuery, ZTeradbConfig } from "@zteradb/client"; // Or using commonJS: const { ZTeraDBConnect, ZTeraDBQuery, ZTeradbConfig } = require('@zteradb/client');
// 1. Setup Configuration
const config = ZTeradbConfig(process.env.ZTERADB_CONFIG);
// 2. Initialize Connection
const db = ZTeraDBConnect(
config,
"<Your ZTeraDB HOST>",
7777
);
// 3. Build ZQL Query
const query = new ZTeraDBQuery("user").select();
// 4. Execute and Stream Results
const users = await db.run(query);
for await (const row of users) {
console.log(row);
}
// 5. Close Connection
db.close();
๐ Documentation Sectionsโ
Explore the rest of our guides to unlock the full potential of ZTeraDB:
- ๐ Configuration โ Learn all available configuration options.
- ๐ Connection โ Deep dive into socket connections and lifecycle management.
- ๐ Query Builder โ Master building fluent ZQL queries.
- ๐๏ธ Filter Conditions โ Apply advanced math and logical filters to your data.
- ๐ณExamples โ Copy-pasteable snippets for common use cases.
- ๐ Troubleshooting Guide โ How to resolve common connection or runtime errors.
- ๐ Quickstart Guide โ A streamlined, 5-minute setup guide.
- ๐ฅ Licence โ Open-source licence terms.
Licenceโ
This project is licenced under the ZTeraDB Licence - see LICENCE file for details.