MarciDB — schema-first NoSQL database server
582
A schema-first NoSQL database written in Rust, with relations, secondary indexes and a fully typed TypeScript client — no ORM layer in between.
model User {
name String
posts Post[] @bind(Post.author)
}
model Post {
title String
views UInt @index
author User?
}
const posts = await db.post.findMany({
title: true,
author: { name: true },
$where: { views: { $gt: 100 } },
$order: { views: "desc" },
$limit: 20,
})
pro | business { ... }) are part of the schema, not application codeselect shape, including discriminated unions for enums$order by index, keyset pagination ($cursor)count / $sum / $avg / $min / $max, including aggregates over relations inside a select (posts: { $count: true } — counted by index keys, without reading rows)db.$transaction([...]) applies several operations as all-or-nothing, with ref("0.id") to feed a generated id into later operationsmarcidb generate diffs it into a migration file; the server applies it on push — adding fields and indexes without rewriting existing rowsCreate schema.marci in your project root.
Generate the typed client and a migration file from the schema:
npm install marcidb-client
npx marcidb generate
docker run -d -p 3000:3000 -v marcidb-data:/app/data den59k/marcidb-server:latest
# or, from the repo: cargo run -p marcidb-server --release
npx marcidb migrate push myapp
import { marcidb } from "marcidb-client"
const db = marcidb("http://localhost:3000/myapp")
const posts = await db.post.findMany({ title: true, author: { name: true } })
The server is published as den59k/marcidb-server:
docker run -d --name marcidb -p 3000:3000 -v marcidb-data:/app/data den59k/marcidb-server:latest
0.0.0.0:$PORT (default 3000)/app/data — mount a volume to persist them across container recreationnpx marcidb migrate push myapp --url http://localhost:3000
# equivalently, over raw HTTP:
curl -X POST http://localhost:3000/myapp/\$migrate --data-binary @schema.marci
Experimental. The storage format is not stabilized yet — do not use for data you cannot regenerate. Migrations cover adding fields, adding/dropping indexes and creating/dropping models; dropping fields, renames and field reordering are not supported yet.
MIT
Content type
Image
Digest
sha256:ade72b1c9…
Size
28.7 MB
Last updated
3 months ago
docker pull den59k/marcidb-server