Skip to main content

Introduction

DortDB is a TypeScript framework for querying data that already lives in your application's memory. Instead of moving arrays, DOM trees, or graphs into a separate database process, you register them as they are and query them in place.

DortDB is not tied to any single query language. The engine is a small, language-neutral core, and query languages are plug-ins. Every language compiles to the same unified algebra, which is what lets a single query mix languages and lets the optimizer reason across the whole plan.

Three languages are provided out of the box, one for each major data model:

PackageLanguageBest for
@dortdb/lang-sqlSQLarrays of objects / row-shaped data
@dortdb/lang-cypherCypherproperty graphs
@dortdb/lang-xqueryXQueryXML, DOM, and tree-shaped data

You choose which languages to load, and you can add your own: the three provided packages are consumers of the same public extension points that are available to you.

What it looks like​

Register a value under a name, then query it:

db.registerSource(['people'], people);

const result = db.query(`
SELECT city, count(*) AS residents
FROM people
GROUP BY city
ORDER BY residents DESC
`);

Registering is O(1)O(1). Nothing is copied, converted, or imported, and there is no schema to declare. Your First Query walks through this from an empty file.

Several languages is the easy part. The distinctive one is embedding one inside another. A LANG block switches languages mid-query, and the inner query can still see the surrounding scope:

db.query(`
SELECT users.name AS name, users.age AS age
FROM users
WHERE users.age > 30 AND (
LANG xquery
fn:count($invoices/customer[. = $users:name])
) > 5
`);

Both halves become one plan, optimized together, so the optimizer can push a filter from the outer query into the nested one. See Mixing Languages for a runnable version.

Why DortDB​

DortDB is language-neutral, schema-agnostic, and modular by design: no language is privileged, sources are plain in-memory values, and the core, each language, and each extension ship as separate packages so a browser bundle carries only what it uses. Design Principles explains what each of those choices buys and what it costs.

Scope and status​

DortDB focuses on querying data that is already loaded. It is not a persistent DBMS and does not handle data modification or storage. The provided SQL, XQuery, and Cypher implementations cover the data-selection subset of each language rather than the full specification; the exact boundaries are documented per language and summarized in Limitations.

Where to next​

  1. Getting Started: install, run your first query, then query two languages at once.
  2. Languages: SQL, Cypher, XQuery.
  3. Guides: Running Queries, Cross-language Queries, Data Sources & Adapters, and Indexing & Performance.
  4. Architecture and the Formalism behind the engine.
  5. Extending DortDB: add languages, functions, adapters, indices, and optimizer rules.
  6. API Reference for exact, generated type signatures.