modelvault 0.15.1

Application-focused embedded database for typed models — validation, migrations, nested objects, single-file deploy.
Documentation
//! Minimal example: in-memory DB (repeatable; no leftover file).
//!
//! Run from the repo root: `cargo run -p modelvault --example open`

use std::borrow::Cow;

use modelvault::prelude::*;
use modelvault::schema::FieldPath;
use modelvault::FieldDef;
use modelvault::Type;

fn main() -> Result<(), DbError> {
    // Setup: in-memory database (no file on disk).
    let mut db = Database::open_in_memory()?;
    println!("opened: {}", db.path().display());
    // Example: register a `books` collection with a string primary key `title`.
    let (id, ver) = db.register_collection(
        "books",
        vec![FieldDef {
            path: FieldPath::new([Cow::Borrowed("title")])?,
            ty: Type::String,
            constraints: vec![],
        }],
        "title",
    )?;
    println!("registered collection id={} version={}", id.0, ver.0);
    Ok(())
}