Guest User

Untitled

a guest
Nov 13th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. /// Define a new struct which derives `Model` & the serde traits.
  2. #[derive(Model, Serialize, Deserialize)]
  3. struct User {
  4. /// This renames the `id` field to match what MongoDB expects for the PK.
  5. #[serde(rename="_id", skip_serializing_if="Option::is_none")]
  6. pub id: Option<ObjectId>,
  7.  
  8. /// This field has a unique index on it.
  9. #[model(index(index_type="dsc", unique="true"))]
  10. pub email: String,
  11. }
Add Comment
Please, Sign In to add comment