pub trait Repository<T: BaseDocument + Debug + Serialize + for<'de> Deserialize<'de>> {
Show 15 methods
// Required methods
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
entity: T,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<ObjectId, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn save_many<'life0, 'life1, 'async_trait>(
&'life0 self,
entities: Vec<T>,
ctx: Option<&'life1 Context>,
options: Option<InsertManyOptions>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ObjectId>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_all_pageable<'life0, 'life1, 'async_trait>(
&'life0 self,
request: PageableRequest,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<PageableResponse<T>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn count_documents_in_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_by_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
ctx: Option<&'life2 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn find_by_raw_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: ObjectId,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_by_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Vec<String>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_by_raw_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
pids: Vec<ObjectId>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_by_filter_and_options<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
options: Option<FindOneOptions>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn find_all_by_filter_and_options<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
options: Option<FindOptions>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
document: &'life1 T,
ctx: Option<&'life2 Context>,
) -> Pin<Box<dyn Future<Output = Result<ObjectId, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn delete_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: ObjectId,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_by_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Vec<ObjectId>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
ctx: Option<&'life1 Context>,
options: Option<FindOneAndDeleteOptions>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_many<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
ctx: Option<&'life1 Context>,
options: Option<DeleteOptions>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Base repository trait. The context passed here is open telemetry context which is useful for telemetry/monitoring purposes
Required Methods§
Sourcefn save<'life0, 'life1, 'async_trait>(
&'life0 self,
entity: T,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<ObjectId, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
entity: T,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<ObjectId, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Save a new document
Sourcefn save_many<'life0, 'life1, 'async_trait>(
&'life0 self,
entities: Vec<T>,
ctx: Option<&'life1 Context>,
options: Option<InsertManyOptions>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ObjectId>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_many<'life0, 'life1, 'async_trait>(
&'life0 self,
entities: Vec<T>,
ctx: Option<&'life1 Context>,
options: Option<InsertManyOptions>,
) -> Pin<Box<dyn Future<Output = Result<Vec<ObjectId>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Save many documents
Sourcefn get_all_pageable<'life0, 'life1, 'async_trait>(
&'life0 self,
request: PageableRequest,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<PageableResponse<T>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_all_pageable<'life0, 'life1, 'async_trait>(
&'life0 self,
request: PageableRequest,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<PageableResponse<T>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get all documents from a collection (pageable)
Sourcefn count_documents_in_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn count_documents_in_collection<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the number of documents in a collection
Sourcefn find_by_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
ctx: Option<&'life2 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn find_by_id<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
ctx: Option<&'life2 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
find a document by ObjectId hex(string)
Sourcefn find_by_raw_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: ObjectId,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_raw_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: ObjectId,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
find a document by ObjectId
Sourcefn find_by_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Vec<String>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Vec<String>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find documents by a list of ObjectId hex(string)
Sourcefn find_by_raw_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
pids: Vec<ObjectId>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_raw_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
pids: Vec<ObjectId>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find documents by a list of ObjectIds
Sourcefn find_by_filter_and_options<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
options: Option<FindOneOptions>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_filter_and_options<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
options: Option<FindOneOptions>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find 1 document by a user defined filter
Sourcefn find_all_by_filter_and_options<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
options: Option<FindOptions>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_all_by_filter_and_options<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
options: Option<FindOptions>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find a list of documents by a user defined filter
Sourcefn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
document: &'life1 T,
ctx: Option<&'life2 Context>,
) -> Pin<Box<dyn Future<Output = Result<ObjectId, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
document: &'life1 T,
ctx: Option<&'life2 Context>,
) -> Pin<Box<dyn Future<Output = Result<ObjectId, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Update an existing document
Sourcefn delete_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: ObjectId,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: ObjectId,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete an existing document by ObjectID
Sourcefn delete_by_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Vec<ObjectId>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_by_ids<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: Vec<ObjectId>,
ctx: Option<&'life1 Context>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a list existing documents by ObjectIDs
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
ctx: Option<&'life1 Context>,
options: Option<FindOneAndDeleteOptions>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
ctx: Option<&'life1 Context>,
options: Option<FindOneAndDeleteOptions>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete an existing document by a user filter
Sourcefn delete_many<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
ctx: Option<&'life1 Context>,
options: Option<DeleteOptions>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_many<'life0, 'life1, 'async_trait>(
&'life0 self,
filter: Document,
ctx: Option<&'life1 Context>,
options: Option<DeleteOptions>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete existing documents by a user defined filter