Skip to main content

text_document_common/direct_access/use_cases/
get_relationship_many.rs

1// Generated by Qleany v1.4.8 from common_da_use_cases_get_relationship_many.tera
2
3use super::traits::ReadRelUoWFactory;
4use crate::types::EntityId;
5use anyhow::Result;
6use std::collections::HashMap;
7
8pub struct GetRelationshipManyUseCase<RF, F: ReadRelUoWFactory<RF>> {
9    uow_factory: F,
10    _phantom: std::marker::PhantomData<RF>,
11}
12
13impl<RF, F: ReadRelUoWFactory<RF>> GetRelationshipManyUseCase<RF, F> {
14    pub fn new(uow_factory: F) -> Self {
15        GetRelationshipManyUseCase {
16            uow_factory,
17            _phantom: std::marker::PhantomData,
18        }
19    }
20
21    pub fn execute(
22        &self,
23        ids: &[EntityId],
24        field: &RF,
25    ) -> Result<HashMap<EntityId, Vec<EntityId>>> {
26        let uow = self.uow_factory.create();
27        uow.begin_transaction()?;
28        let result = uow.get_relationship_many(ids, field)?;
29        uow.end_transaction()?;
30        Ok(result)
31    }
32}