@dbcube/core
v5.2.18
Published
DBCube core runtime: manages the Rust query/schema engines (daemon mode, binary download, config loading) shared by the query builder, schema builder and ORM.
Maintainers
Keywords
Readme
@dbcube/core
Core runtime for the DBCube ecosystem. You normally don't install this package directly — it ships as a dependency of dbcube (the ORM), @dbcube/query-builder and @dbcube/schema-builder.
What it does
- Engine management: downloads, versions and runs the Rust
query-engineandschema-enginebinaries for your platform. - Daemon mode: keeps the query engine alive as a local TCP server with warm connection pools (sub-millisecond dispatch), with automatic fallback to one-shot mode. Disable with
DBCUBE_DAEMON=0. - Config loading: parses
dbcube.config.js(config.set({ databases: { ... } })) and exposes per-database settings. - Pool tuning: the optional
poolblock per database —maxConnections,minConnections,acquireTimeoutMs,idleTimeoutMsandsessionIdleTimeoutMs. - Processors: computed fields (
@compute/@columnin.cubefiles), trigger metadata and schema diffing used bytable:refresh.
Resilient connections in containers
If Dbcube runs in a container that crashes and restarts repeatedly, connections
left behind by each ungraceful death can pile up on the database until it runs out.
pool.sessionIdleTimeoutMs (default 300000 ms = 5 min) tells the database itself
to drop sessions left idle longer than that — mapping to wait_timeout (MySQL),
idle_session_timeout (PostgreSQL 14+) and maxIdleTimeMS (MongoDB) — so orphans
are reaped in minutes instead of hours. Live pooled connections are unaffected. Set
it to 0 to disable. Requires query-engine v1.1.3+. Full details on
dbcube.dev.
Usage
const { QueryEngine } = require("@dbcube/core");
const engine = new QueryEngine("myapp"); // name from dbcube.config.js
const res = await engine.rawQuery("SELECT 1");For application code use the dbcube ORM instead.
Documentation
https://dbcube.dev
License
MIT
