@dortdb/core
The language-neutral engine at the heart of DortDB, a modular framework for querying JavaScript data that already lives in your application's memory.
@dortdb/core owns the whole query lifecycle (source registration, planning,
optimization, and execution) together with every extension point, but it ships
no query language of its own. You pair it with one or more language packages:
@dortdb/lang-sql: SQL over arrays of objects@dortdb/lang-cypher: Cypher-based queries over property graphs@dortdb/lang-xquery: XQuery over XML, DOM, and tree-shaped data
Installation
npm install @dortdb/core @dortdb/lang-sql
Each language declares @dortdb/core as a peer dependency, so a single core
instance is shared across all of them.
Usage
import { DortDB } from '@dortdb/core';
import { defaultRules } from '@dortdb/core/optimizer';
import { SQL } from '@dortdb/lang-sql';
const db = new DortDB({
mainLang: SQL(),
optimizer: { rules: defaultRules },
});
const users = [
{ name: 'Alice', age: 30 },
{ name: 'Bob', age: 25 },
{ name: 'Charlie', age: 35 },
];
// registering a source just pairs data with a name: no copying, no import
db.registerSource(['users'], users);
const result = db.query(`
SELECT name, age
FROM users
WHERE age > 30
`);
// result.schema -> ['name', 'age']
// result.data -> [{ name: 'Charlie', age: 35 }]
What's in the box
- The
DortDBengine class, plusparse/buildPlan/executePlanfor step-by-step control. - A rule-based optimizer and the pre-ordered
defaultRulesset. - Index abstractions (
MapIndex, hash joins) for faster lookups and joins. - Extension points for languages, functions, aggregates, operators, castables, data adapters, index types, and optimizer rules.
Because the core and each language are separate packages, a browser bundle includes only the languages and extensions you actually import.
Documentation
Full documentation lives at filipjezek.github.io/dortdb, including the architecture, the unified algebra every language compiles to, and the extension model. A generated API reference covers the exact type signatures.
Try the live demo to build queries and watch their plans.