marcidb-client
v0.8.1
Published
TypeScript client for [MarciDB](https://github.com/den59k/marci-db.git) — a NoSQL database with a schema-first approach.
Readme
marci-db
TypeScript client for MarciDB — a NoSQL database with a schema-first approach.
Installation
npm install marcidb-client
# or
bun add marcidb-clientSetup
- Create a
schema.marcifile in your project root:
model User {
name String
posts Post[] @bind(Post.author)
}
model Post {
title String
author User?
}- Generate the client:
marcidb generate
# or with custom paths
marcidb generate schema.marci node_modules/.marcidb/client- Start your MarciDB server and connect:
import { marcidb } from "marcidb-client";
const db = marcidb("http://localhost:3000");Usage
import { marcidb } from "marcidb-client";
const db = marcidb("http://localhost:3000");
// Find
const users = await db.user.findMany({
id: true,
name: true,
});
// Insert
const id = await db.user.insert({
name: "Alice",
});
// Update
await db.user.update({ id: 1 }, {
name: "Bob",
});
// Delete
await db.user.delete({ id: 1 });Requirements
- Node.js 18+ or Bun
- MarciDB server running
Re-generating types
After every change to schema.marci, re-run:
marcidb generateIf types don't update in VSCode, run TypeScript: Restart TS Server (Ctrl+Shift+P).
