fix
This commit is contained in:
parent
05e09295a5
commit
9b56a434e7
2 changed files with 14 additions and 4 deletions
|
@ -3,8 +3,10 @@ pub use model::historic::Historic;
|
|||
pub use model::reference::*;
|
||||
pub use model::valid::Validate;
|
||||
pub use model::Model;
|
||||
pub use model::Sort;
|
||||
pub use mongod_derive as derive;
|
||||
pub use mongodb;
|
||||
|
||||
#[cfg(feature = "cache")]
|
||||
pub mod cache;
|
||||
#[cfg(feature = "cache")]
|
||||
|
|
|
@ -354,11 +354,19 @@ pub trait Model:
|
|||
/// "sort_key": Sort::Ascending
|
||||
/// })).await.unwrap();
|
||||
/// ```
|
||||
#[repr(i8)]
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub enum Sort {
|
||||
/// Sort in ascending order
|
||||
Ascending = 1,
|
||||
Ascending,
|
||||
/// Sort in descending order
|
||||
Descending = -1,
|
||||
Descending,
|
||||
}
|
||||
|
||||
impl Into<mongodb::bson::Bson> for Sort {
|
||||
fn into(self) -> mongodb::bson::Bson {
|
||||
match self {
|
||||
Sort::Ascending => mongodb::bson::bson!(1),
|
||||
Sort::Descending => mongodb::bson::bson!(-1),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue