Crate mongod_derive

source ·
Expand description

§Mongo Derive

This crate provides two derives Bson & Mongo for the mongo crate.

§Examples

Deriving BSON

#[derive(Bson)]
pub struct User {
    name: String,
    age: u32,
}

Deriving Mongo

#[derive(Mongo)]
#[mongo(collection = "users", field, filter, update)]
pub struct User {
    name: String,
    age: u32,
}

Derive Macros§

  • Derives implementations for TryFrom so that the decorated type can be converted to & from BSON.
  • Derives mongo traits on the decorated type.