wasm-dbms
A runtime-agnostic DBMS engine for WASM environments. Define your database schema using Rust structs with derive macros and get CRUD operations, ACID transactions, foreign key integrity, and validation out of the box.
Crate Architecture
wasm-dbms is part of a family of crates:
wasm-dbms-macros <── wasm-dbms-api <── wasm-dbms-memory <── wasm-dbms
| Crate | Description |
|---|---|
wasm-dbms-api |
Shared types, traits, validators, sanitizers |
wasm-dbms-memory |
Memory abstraction and page management |
wasm-dbms |
Core DBMS engine with transactions, joins, integrity checks |
wasm-dbms-macros |
Procedural macros: Encode, Table, CustomDataType |
Quick Start
Add the dependencies to your Cargo.toml:
[]
= "0.6"
= "0.6"
Define Your Tables
use *;
Required derives: Table, Clone
Define Relationships
Create a Database Schema
Wire your tables together with #[derive(DatabaseSchema)]:
use DatabaseSchema;
;
Use the Database
use *;
use *;
// Create the context (owns all database state)
let ctx = new;
register_tables.expect;
// Create a one-shot (non-transactional) database session
let database = oneshot;
// Insert a record
let user = UserInsertRequest ;
database.?;
// Query records
let query = builder
.filter
.build;
let users = database.?;
Transactions
use *;
use *;
// Begin a transaction
let tx_id = ctx.begin_transaction;
let mut database = from_transaction;
database.?;
database.?;
// Commit or rollback
database.commit?;
// database.rollback()?;
Features
- CRUD operations with type-safe insert/update/select/delete
- ACID transactions with commit and rollback
- Foreign key relationships with referential integrity
- Complex queries with filtering, ordering, and pagination
- JOIN operations between tables
- Validation and sanitization on table columns
- Custom data types
- Runtime-agnostic: works on any WASM runtime (Wasmtime, Wasmer, WasmEdge, Internet Computer, etc.)
Documentation
Read the full documentation at https://wasm-dbms.cc
License
This project is licensed under the MIT License. See the LICENSE file for details.