musty is currently in very early development. the musty book is a work-in-progress.

Introduction

musty is an asynchronous object-document mapper library for Rust. It turns your struct's into queryable database models.

Features

  • Typed model filter/querying language via filter!() macro.
  • Support for multiple different database backends.
  • Automatically handles serializing, deserializing, id mapping, & more.
  • Straight-forward integration, requiring little change to your data structs.
  • Focus on extendability, underlying database driver is always available for advanced querying.
  • Easily define indexes and dynamic get_by functions using the #[musty()] macro.

Why use musty?

  • Spend less time building an ODM and more time building your app.
  • Leverage typed database-agnostic document queries using the filter!() macro.
  • Ability to switch to a different database backend down the line with little to no code changes.

Getting Started

musty is designed to integrate with little friction (i.e: not enforcing specific types to be used, etc), for how to get started using musty, check out the quick start.

Quick start

Add dependency

[dependencies]
musty = "0.0.0"

Model your data struct

#![allow(unused)]
fn main() {
use musty::prelude::*;

#[model(mongo())]
struct User {
    #[musty(get_by)]
    name: String
}
}

Save/query your model

...

#[tokio::main]
async fn main() -> musty::Result<()> {
    let db = ...

    let mut user = User::new("alex"); // fn generated by macro
    user.save(&db).await?;

    let mut user = User::get_by_name("alex").await?; // generated by #[musty(get_by)]
    user.delete(&db).await?;
}

Database

Model

Identifiers

DB-generated identifiers

Creating a model