1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! An ODM for MongoDB built upon the [mongo rust driver](https://github.com/mongodb-labs/mongo-rust-driver-prototype).
//!
//! This project makes use of `associated constants` as of `0.2.0`, so you will need to be running rust `>= 1.20`.
//!
//! An example of how you might use this library to define a model for a MongoDB collection.
//!
//! ```rust,ignore
//! #[derive(Serialize, Deserialize, Debug, Clone)]
//! pub struct User {
//!     /// The user's unique ID.
//!     #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
//!     pub id: Option<bson::oid::ObjectId>,
//!
//!     /// The user's unique email.
//!     pub email: String,
//! }
//!
//! impl<'a> wither::Model<'a> for User {
//!
//!     const COLLECTION_NAME: &'static str = "users";
//!
//!     fn id(&self) -> Option<bson::oid::ObjectId> {
//!         return self.id.clone();
//!     }
//!
//!     fn set_id(&mut self, oid: bson::oid::ObjectId) {
//!         self.id = Some(oid);
//!     }
//!
//!     fn indexes() -> Vec<IndexModel> {
//!         return vec![
//!             IndexModel{
//!                 keys: doc!{"email" => 1},
//!                 options: wither::basic_index_options("unique-email", true, Some(true), None, None),
//!             },
//!         ];
//!     }
//! }
//! ```

#[macro_use(doc, bson)]
extern crate bson;
extern crate mongodb;
extern crate serde;

pub use bson::Document;
pub use mongodb::coll::options::FindOptions;

pub mod model;

// Expose lower symbols in the top level module.
pub use model::Model;
pub use model::basic_index_options;