{"id":13995432,"url":"https://github.com/thedodd/wither","last_synced_at":"2025-05-16T18:11:01.809Z","repository":{"id":24140720,"uuid":"100730941","full_name":"thedodd/wither","owner":"thedodd","description":"An ODM for MongoDB built on the official MongoDB Rust driver.","archived":false,"fork":false,"pushed_at":"2023-01-20T23:29:21.000Z","size":462,"stargazers_count":340,"open_issues_count":24,"forks_count":42,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-12T17:46:29.742Z","etag":null,"topics":["databases","mongodb","odm","orm","rust","rust-library"],"latest_commit_sha":null,"homepage":"https://docs.rs/wither","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thedodd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-18T16:29:14.000Z","updated_at":"2025-04-08T05:55:08.000Z","dependencies_parsed_at":"2023-02-12T06:45:23.918Z","dependency_job_id":null,"html_url":"https://github.com/thedodd/wither","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedodd%2Fwither","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedodd%2Fwither/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedodd%2Fwither/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedodd%2Fwither/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thedodd","download_url":"https://codeload.github.com/thedodd/wither/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582907,"owners_count":22095518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["databases","mongodb","odm","orm","rust","rust-library"],"created_at":"2024-08-09T14:03:24.484Z","updated_at":"2025-05-16T18:11:01.772Z","avatar_url":"https://github.com/thedodd.png","language":"Rust","readme":"\u003ch1 align=\"center\"\u003ewither\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n    \u003cstrong\u003e\nAn ODM for MongoDB built on the official \u003ca href=\"https://github.com/mongodb/mongo-rust-driver\"\u003eMongoDB Rust driver\u003c/a\u003e. Please ⭐ on \u003ca href=\"https://github.com/thedodd/wither\"\u003egithub\u003c/a\u003e!\n    \u003c/strong\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![Build Status](https://github.com/thedodd/wither/workflows/ci/badge.svg?branch=master)](https://github.com/thedodd/wither/actions)\n[![](https://img.shields.io/badge/tested%20on-mongodb%203.6%2B-brightgreen.svg)](#)\n[![Crates.io](https://img.shields.io/crates/v/wither.svg)](https://crates.io/crates/wither)\n[![docs.rs](https://docs.rs/wither/badge.svg)](https://docs.rs/wither)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n![Crates.io](https://img.shields.io/crates/d/wither.svg)\n\n\u003c/div\u003e\n\u003c/br\u003e\n\nThe primary goal of this project is to provide a simple, sane \u0026 predictable interface into MongoDB based on data models. If at any point this system might get in your way, you have direct access to the underlying driver. This project is tested against MongoDB `3.6`, `4.0`, `4.2` \u0026 `4.4`.\n\n**GREAT NEWS!** Wither is now based on the official [MongoDB Rust driver](https://github.com/mongodb/mongo-rust-driver). Thanks to advancements in the driver, Wither is now fully asynchronous. Simply mirroring the features of the underlying MongoDB driver, Wither supports the following runtimes:\n- `tokio-runtime` (default) activates [the tokio runtime](tokio.rs/).\n- `async-std-runtime` activates [the async-std runtime](https://async.rs/).\n\nDue to updates in the underlying driver, there is a fair number of breaking changes in the `Model` trait, as well as the `Model` derive macro. Details can be found in the changelog and the documentation. Furthermore, everything is now async by default, and the synchronous interface has been completely removed from the repo.\n\n### items of interest\n- [docs](https://docs.rs/wither): all the good stuff is here.\n- [changelog](https://github.com/thedodd/wither/blob/master/CHANGELOG.md): details on what has happened from release to release.\n- [contributing \u0026 development guidelines](https://github.com/thedodd/wither/blob/master/CONTRIBUTING.md): details on how to get started with doing development on this project.\n\n### getting started\nTo get started, simply derive `Model` on your struct along with a few other serde derivations. Let's step through a full example.\n\n```rust ,no_run\nuse futures::stream::StreamExt;\nuse serde::{Serialize, Deserialize};\nuse wither::{prelude::*, Result};\nuse wither::bson::{doc, oid::ObjectId};\nuse wither::mongodb::Client;\n\n// Define a model. Simple as deriving a few traits.\n#[derive(Debug, Model, Serialize, Deserialize)]\n#[model(index(keys=r#\"doc!{\"email\": 1}\"#, options=r#\"doc!{\"unique\": true}\"#))]\nstruct User {\n    /// The ID of the model.\n    #[serde(rename=\"_id\", skip_serializing_if=\"Option::is_none\")]\n    pub id: Option\u003cObjectId\u003e,\n    /// The user's email address.\n    pub email: String,\n}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    // Connect \u0026 sync indexes.\n    let db = Client::with_uri_str(\"mongodb://localhost:27017/\").await?.database(\"mydb\");\n    User::sync(\u0026db).await?;\n\n    // Create a user.\n    let mut me = User{id: None, email: String::from(\"my.email@example.com\")};\n    me.save(\u0026db, None).await?;\n\n    // Update user's email address.\n    me.update(\u0026db, None, doc!{\"$set\": doc!{\"email\": \"new.email@example.com\"}}, None).await?;\n\n    // Fetch all users.\n    let mut cursor = User::find(\u0026db, None, None).await?;\n    while let Some(user) = cursor.next().await {\n        println!(\"{:?}\", user);\n    }\n    Ok(())\n}\n```\n\n#### next steps\nAnd that's all there is to it. Now you are ready to tackle some of the other important parts of the model lifecycle. Some additional items to look into:\n\n- [deriving model](https://docs.rs/wither/latest/wither/model/trait.Model.html) - learn more about automatically deriving the `Model` trait on your structs.\n- [model usage](https://docs.rs/wither/latest/wither/model/trait.Model.html#provided-methods) - check out some of the other methods available to you from your models.\n- [syncing indexes](https://docs.rs/wither/latest/wither/model/trait.Model.html#sync) - learn how to synchronize a model's indexes with the database.\n- [logging](https://docs.rs/wither/latest/wither/model/trait.Model.html#logging) - learn how to hook into this crate's logging mechanisms.\n- [migrations](https://docs.rs/wither/latest/wither/migration/index.html) - learn about defining migrations to be run against your model's collection.\n\nGood luck on the path.\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedodd%2Fwither","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthedodd%2Fwither","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedodd%2Fwither/lists"}