| Crates.io | mondm |
| lib.rs | mondm |
| version | 0.0.1 |
| created_at | 2025-07-13 02:40:10.255338+00 |
| updated_at | 2025-07-13 02:40:10.255338+00 |
| description | a lightweight, async-friendly, type-safe ODM (Object-Document Mapper) for MongoDB in the Rust ecosystem. |
| homepage | https://github.com/rustkit/mondm |
| repository | https://github.com/rustkit/mondm |
| max_upload_size | |
| id | 1749909 |
| size | 6,934 |
๐๏ธ mondm is a lightweight, async-friendly, type-safe ODM (Object-Document Mapper) for MongoDB in the Rust ecosystem.
Built on top of the official mongodb driver and inspired by simplicity, mondm helps you map Rust structs to MongoDB documents with minimal boilerplate and maximum control.
#[derive(Model)] style document mapping_id (ObjectId) supportinsert, find, update, deleteCargo.toml[dependencies]
mondm = "0.1"
mongodb = { version = "2", default-features = false, features = ["tokio-runtime"] }
serde = { version = "1", features = ["derive"] }
use mondm::{Model, MongoModel};
use serde::{Deserialize, Serialize};
use bson::oid::ObjectId;
#[derive(Debug, Serialize, Deserialize, Model)]
#[mondm(collection = "users")]
pub struct User {
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
pub id: Option<ObjectId>,
pub name: String,
pub email: String,
}
use mondm::MongoRepository;
use mongodb::Client;
#[tokio::main]
async fn main() -> mongodb::error::Result<()> {
let client = Client::with_uri_str("mongodb://localhost:27017").await?;
let db = client.database("test");
let repo = MongoRepository::<User>::new(&db);
let user = User {
id: None,
name: "Alice".into(),
email: "alice@example.com".into(),
};
repo.insert(&user).await?;
let fetched = repo.find_by_id(user.id.as_ref().unwrap()).await?;
println!("Fetched user: {:?}", fetched);
Ok(())
}
This project is dual-licensed under either: