MongrelDB Kit
The application-facing persistence layer for MongrelDB - schema-aware query builder, migrations, relational constraints, and stable semantics across TypeScript, Rust, Python, and CLI surfaces.
Packages And Tools
| Surface | Package / crate | Install or run |
|---|---|---|
| TypeScript | @visorcraft/mongreldb-kit |
npm install @visorcraft/mongreldb-kit @visorcraft/mongreldb |
| Rust | mongreldb-kit |
cargo add mongreldb-kit |
| Python | mongreldb-kit |
pip install mongreldb-kit |
| CLI | mongreldb-kit-cli (mongreldb-kit binary) |
cargo run -p mongreldb-kit-cli -- --help |
What It Provides
- Schema helpers for typed tables, stable table/column ids, defaults, indexes, checks, unique constraints, and foreign keys. Full type set: int64, float64, bool, text, bytes (BLOB), timestamp, date, date64, time64, interval, decimal128, UUID, JSON, and array columns.
- Synchronous TypeScript CRUD/query builder with predicates, ordering, projections, aggregates, joins, subqueries, CTEs, batch inserts, updates, and deletes.
- Rust and Python APIs backed by the same Rust core and verified with cross-language conformance fixtures.
- Migration runner with content-addressed checksums, stored schema catalog, table renames, and SQL views.
- Embedded SQL surface (sql / sqlArrow / sqlRows) with recursive CTEs, window functions, CREATE TABLE AS SELECT, materialized views, multi-statement execution, and a mongreldb_fts_rank relevance-scoring UDF.
- Storage tuning (spill thresholds, compaction zstd, result-cache sizing, index build policy), trigger config, and per-table introspection (run count, page-cache stats, memtable/cache lengths).
- Maintenance:
analyze/vacuum(compact+gc) andcheckpoint()to flush, compact, and drop rotated WAL segments so recovery stays bounded (MongrelDB 0.64.18+). - BinarySign and full-f32 Dense ANN schema options, plus durable online create/replace index jobs with status, cancellation, resume, and wait APIs in Rust, TypeScript, and Python.
- Non-blocking async I/O variants (
putAsync/queryAsync/countAsync/ …) andWriteBuffermicro-batching for high-throughput ingest (TypeScript). - Engine-side trigger management plus SQL-backed virtual/external table helpers.
- Extended SQL Function helpers for JSON, date/time, aggregate, and math-style SQL calls.
- User/role/credentials management with optional storage-layer enforcement: Argon2id-hashed catalog users, roles,
GRANT/REVOKEtable-level permissions, daemon HTTP Basic + Bearer auth, and opt-inrequire_authcredential enforcement (credentialed open/create constructors,enable_auth/disable_auth, offline recovery) - exposed through every language API, the embedded SQL surface, and the CLI (user/role/authsubcommands). - Relational constraint enforcement on top of MongrelDB transactions: not-null, type/range/string validation, unique/composite unique, foreign keys, and cascade/set-null/restrict deletes.
- Multi-process file locking, replication, and change-data-capture via the daemon.
Documentation
- Overview
- TypeScript quickstart
- Rust quickstart
- Python quickstart
- CLI
- Schema DSL
- Types
- Defaults
- Query builder
- Migrations
- Triggers
- Extended SQL & virtual tables
- Constraints
- Transactions
- SQL cancellation and timeouts
- Errors
- Internal tables
- Testing
- Production checklist
History retention and time-travel reads
Both the embedded KitDatabase and the daemon client RemoteDatabase expose
history-retention controls:
// TypeScript
db.setHistoryRetentionEpochs(100); // embedded: number argument
remote.setHistoryRetentionEpochs(100n); // remote: bigint argument
console.log(db.historyRetentionEpochs()); // bigint
console.log(remote.historyRetentionEpochs()); // bigint
console.log(db.earliestRetainedEpoch()); // bigint
# Python (embedded)
db.set_history_retention_epochs(100)
print(db.history_retention_epochs()) # int
print(db.earliest_retained_epoch()) # int
# Python (remote)
remote.set_history_retention_epochs(100)
print(remote.history_retention_epochs())
print(remote.earliest_retained_epoch())
Set retention before writing the data you want to time-travel back to.
Embedded databases initially keep only the latest epoch. The daemon defaults
to 1024 epochs unless MONGRELDB_HISTORY_RETENTION_EPOCHS overrides it.
Increasing retention later cannot restore history that has already been
removed. Read past snapshots with
db.rowsAtEpoch('table', epoch) (embedded) or SELECT ... AS OF EPOCH <epoch>
(embedded SQL and the daemon).
Quick Example
Minimal TypeScript schema and CRUD flow:
TypeScript
import {
KitDatabase,
Schema,
table,
int,
text,
sequenceDefault,
unique,
eq
} from '@visorcraft/mongreldb-kit';
const users = table('users', {
columns: [
int('id', { primaryKey: true, default: sequenceDefault('users_id_seq') }),
text('email', { nullable: false }),
text('name', { nullable: true })
],
primaryKey: 'id',
unique: [unique(['email'], { name: 'users_email_uq' })]
});
const schema = new Schema([users]);
const db = KitDatabase.openSync('./app-data', schema);
db.migrateSync(schema, [
{
version: 1,
name: 'initial',
up({ ensureTable }) {
ensureTable(users);
}
}
]);
const alice = db.insertInto(users)
.values({ email: 'alice@example.com', name: 'Alice' })
.executeSync();
const [row] = db.selectFrom(users)
.where(eq(users.id, alice.id))
.executeSync();
console.log(row);
db.close();
See the language docs for complete runnable examples in TypeScript, Rust, and Python.
Development Notes
- TypeScript requires Node.js 22+ and the native
@visorcraft/mongreldbpeer dependency. - A MongrelDB database path is a data directory, not a single database file.
- In this mono-repo checkout, the TypeScript package loads the native addon from the sibling MongrelDB repo. Build
crates/mongreldb-nodethere withnpm run buildin release mode before benchmarking; stale debug.nodebuilds make bulk paths much slower.
Building and testing
# Rust
rtk cargo check --workspace
rtk cargo test --workspace
# TypeScript
cd packages/kit
rtk npm ci
rtk npm run build
rtk npm run check
rtk npm test
# Python
cd python/mongreldb_kit
rtk python -m venv .venv
rtk .venv/bin/pip install maturin
rtk maturin develop
rtk .venv/bin/pytest ../../python/tests ../../tests/conformance/python
# CLI
rtk cargo run -p mongreldb-kit-cli -- --help
Related tools
- Mongrel — Commercial multi-system workbench with native MongrelDB support.
- MongrelDB Viewer — Free, open-source MongrelDB GUI and MCP server.
License
MIT OR Apache-2.0
Metadata
Release files for mongreldb-kit 0.64.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| mongreldb_kit-0.64.19-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| mongreldb_kit-0.64.19-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| mongreldb_kit-0.64.19-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| mongreldb_kit-0.64.19-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| mongreldb_kit-0.64.19-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 260.0 MB
Release files / mongreldb_kit-0.64.19-cp310-abi3-win_amd64.whl
| Download URL | mongreldb_kit-0.64.19-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 49.0 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cef75af6e995a9b62749a276cfe0fdd6b3fd9ac8c4dd2637bf8f96b8133cee8b
|
|
BLAKE2b-256 checksum How to use checksums |
1a91c79d3116450b2b354c2d71a2e7d2be82620feee37e15e6e991c5a377d5b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logRelease files / mongreldb_kit-0.64.19-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | mongreldb_kit-0.64.19-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 54.8 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
725b6ec0b6e41d8212ca3b217e5737c1977f16cde96eb89c1896493a69194ac3
|
|
BLAKE2b-256 checksum How to use checksums |
e6234fbcc656ad9b2bd8fc9fdfd80e1e7a49f6b37e0027ea6c73fd48ac11f04e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logRelease files / mongreldb_kit-0.64.19-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | mongreldb_kit-0.64.19-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 56.1 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
b1220b94fb17fdba8d08b01b70704cd33877a7b3929605824833f7666ac80a98
|
|
BLAKE2b-256 checksum How to use checksums |
4fb38e4f7e37e35d59672927e869919b83065a46a29d98b3de83e5879a32ac48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logRelease files / mongreldb_kit-0.64.19-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | mongreldb_kit-0.64.19-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 49.0 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1d4f85b1cc2821aef2eb7131cd2f89a94dcf5162a527f994c2d682f9744a0831
|
|
BLAKE2b-256 checksum How to use checksums |
3b52404c9f62fa053088251e2a9e47132d382d1c75255f5ad838dea8b83d9271
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logRelease files / mongreldb_kit-0.64.19-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | mongreldb_kit-0.64.19-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 51.0 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
951f50386a275b17576287f50069a4bfa7ecb55e0c33aff50e7c74e17b61bf72
|
|
BLAKE2b-256 checksum How to use checksums |
53634ac96e8d2e161de3a6efbc6add5399f8be5f1f71ccfafe1b4e6e3013dcd9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency log