Skip to main content

datasources/
bulk_write_strategy.rs

1use crate::command::Command;
2use crate::connection::Connection;
3use crate::crud_repository::CRUDRepository;
4use crate::crud_repository_options::CRUDRepositoryOptions;
5use crate::IWhere;
6use crate::response::Response;
7use crate::result::Result;
8use crate::row::Row;
9use async_trait::async_trait;
10use std::sync::Arc;
11
12#[async_trait]
13pub trait BulkWriteStrategy: Send + Sync {
14    fn set_repo(&self, repo: Arc<CRUDRepository>) {
15        let _ = repo;
16    }
17
18    fn attach(
19        &self,
20        command: Arc<dyn Command>,
21        options: CRUDRepositoryOptions,
22        connection: Arc<dyn Connection>,
23    ) {
24        let _ = (command, options, connection);
25    }
26
27    fn persist_children(&self) -> bool {
28        false
29    }
30
31    async fn create(&self, items: &mut [Row]) -> Result<Response>;
32    async fn update(&self, items: &[Row], by_where: Option<&dyn IWhere>) -> Result<Response>;
33    async fn delete(&self, items: &[Row], by_where: Option<&dyn IWhere>) -> Result<Response>;
34}