This commit is contained in:
JMARyA 2024-08-28 08:50:38 +02:00
parent 05e09295a5
commit 9b56a434e7
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 14 additions and 4 deletions

View file

@ -3,8 +3,10 @@ pub use model::historic::Historic;
pub use model::reference::*; pub use model::reference::*;
pub use model::valid::Validate; pub use model::valid::Validate;
pub use model::Model; pub use model::Model;
pub use model::Sort;
pub use mongod_derive as derive; pub use mongod_derive as derive;
pub use mongodb; pub use mongodb;
#[cfg(feature = "cache")] #[cfg(feature = "cache")]
pub mod cache; pub mod cache;
#[cfg(feature = "cache")] #[cfg(feature = "cache")]

View file

@ -354,11 +354,19 @@ pub trait Model:
/// "sort_key": Sort::Ascending /// "sort_key": Sort::Ascending
/// })).await.unwrap(); /// })).await.unwrap();
/// ``` /// ```
#[repr(i8)] #[derive(Debug)]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub enum Sort { pub enum Sort {
/// Sort in ascending order /// Sort in ascending order
Ascending = 1, Ascending,
/// Sort in descending order /// 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),
}
}
} }