Package Exports
- @triyatna/aingdb
- @triyatna/aingdb/cli
- @triyatna/aingdb/features
Readme
AingDB
AingDB is a modern embedded database. Small, fast, encrypted, and intelligent.
Install
npm i @triyatna/aingdbQuick Start
import { AingDB } from "@triyatna/aingdb";
const db = await AingDB.open({
path: "./app.msdb",
encryption: {
enabled: true,
algorithm: "aes-256-gcm",
kdf: "scrypt",
passphrase: "secret",
},
});
await db.schema.create({
name: "users",
columns: [
{ name: "id", type: "uuid", primary: true },
{ name: "email", type: "string", unique: true },
{ name: "name", type: "text" },
],
});
await db.table("users").insert({ id: "u1", email: "a@b.com", name: "Ana" });
const rows = await db.table("users").find({ email: "a@b.com" });
await db.close();Feature Highlights
- Encrypted single-file WAL + immutable audit trail
- SQL: SELECT +
WITHCTE,INNER/LEFT JOIN,WHERE,GROUP BY+ agregat, Window (ROW_NUMBER,RANK,DENSE_RANK,LAG/LEAD),ORDER BY,LIMIT,RETURNING - Optimizer: cost-based (ringan) dengan
ANALYZEstats, predicate pushdown, IndexScan vs SeqScan, nested-loop join index-aware - Indexes: multi-kolom, partial (predicate), expression (mis.
LOWER(email)), Index Advisor - Vector: HNSW multi-level (cosine/L2), efSearch dinamis, persistensi graf
- Search: FTS-lite (
MATCH()), RTREE-lite (INTERSECTS()) - Observability:
/metrics(Prometheus),/healthz
CLI
# bantuan
npx aingdb help
# jalankan SQL
npx aingdb sql --path ./app.msdb -e "SELECT * FROM users LIMIT 10"
# EXPLAIN/ANALYZE
npx aingdb explain --path ./app.msdb -e "SELECT u.id FROM users u LEFT JOIN orders o ON u.id=o.userId"
# ANALYZE & saran indeks
npx aingdb analyze --path ./app.msdb
npx aingdb advise-index --table users --workload '[{"whereCols":["email"],"joinOn":["id"]}]'
# buat index (multi-col/expression/partial)
npx aingdb create-index --path ./app.msdb --name users_email_idx --table users --columns "email"
npx aingdb create-index --path ./app.msdb --name users_email_lower_act --table users --expr "LOWER(email)" --partial "status == 'active'"Change Log
v0.0.19Fix Bugv0.0.17Add SQL in CLIv0.0.15Release
Lisensi: MIT · © Tri Yatna