Skip to main content

text_document_common/direct_access/use_cases/
get_relationship_in_range.rs

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