Skip to main content

SecureFindRelatedExt

Trait SecureFindRelatedExt 

Source
pub trait SecureFindRelatedExt: ModelTrait {
    // Required method
    fn secure_find_related<R>(
        &self,
        r: R,
        scope: &AccessScope,
    ) -> SecureSelect<R, Scoped>
       where R: ScopableEntity + EntityTrait,
             R::Column: ColumnTrait + Copy,
             Self::Entity: Related<R>;
}
Expand description

Extension trait to perform secure find_related queries from a model instance.

This trait provides a way to find entities related to an already-loaded model while maintaining security scope constraints.

§Example

use modkit_db::secure::{AccessScope, SecureFindRelatedExt};

// Load a cake
let cake: cake::Model = db.find_by_id::<cake::Entity>(&scope, cake_id)?
    .one(db)
    .await?
    .unwrap();

// Find all related fruits with scoping
let fruits: Vec<fruit::Model> = cake
    .secure_find_related(fruit::Entity, &scope)
    .all(db)
    .await?;

Required Methods§

Find related entities with access scope applied.

This creates a scoped query for entities related to this model. The scope is applied to the related entity to ensure tenant isolation.

§Type Parameters
  • R: The related entity type that must implement ScopableEntity
§Arguments
  • r: The related entity marker (e.g., fruit::Entity)
  • scope: The access scope to apply to the related entity query

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§