add find_all
This commit is contained in:
parent
c4f2b6eb81
commit
84ef28312e
1 changed files with 15 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
use mongodb::{
|
||||
bson::doc,
|
||||
options::{FindOneOptions, FindOptions},
|
||||
results::{DeleteResult, InsertOneResult},
|
||||
};
|
||||
|
@ -175,6 +176,20 @@ pub trait Model:
|
|||
}
|
||||
}
|
||||
|
||||
/// Get all `Model`s from the database
|
||||
#[must_use]
|
||||
fn find_all() -> impl std::future::Future<Output = Option<Vec<Self>>> {
|
||||
Self::find(doc! {}, None)
|
||||
}
|
||||
|
||||
/// Get all `Model`s partial from the database
|
||||
#[must_use]
|
||||
fn find_all_partial(
|
||||
part: serde_json::Value,
|
||||
) -> impl std::future::Future<Output = Option<Vec<Self::Partial>>> {
|
||||
Self::find_partial(doc! {}, part, None)
|
||||
}
|
||||
|
||||
/// Get multiple `Model`s by using a filter from the database. Pass a `limit` parameter to limit the amount of `Model`s returned.
|
||||
#[must_use]
|
||||
fn find(
|
||||
|
|
Loading…
Reference in a new issue