pub struct TenantScope<C: ColumnTrait>(pub C);Expand description
A query scope that filters by the current tenant’s ID.
Wraps a single ColumnTrait value representing the tenant foreign-key
column. When Scope::apply is called, it reads the tenant ID from
task-local context and appends .eq(tenant_id) to the query.
§Panics
Panics with a clear message if called outside a TenantMiddleware scope.
This is intentional — using TenantScope without middleware is a
programming error, not a recoverable runtime condition.
§Example
ⓘ
use ferro_rs::TenantScope;
let posts = post::Entity::scoped(TenantScope(post::Column::TenantId))
.all()
.await?;Tuple Fields§
§0: CTrait Implementations§
Source§impl<E, C> Scope<E> for TenantScope<C>
impl<E, C> Scope<E> for TenantScope<C>
Source§fn apply(self, query: QueryBuilder<E>) -> QueryBuilder<E>
fn apply(self, query: QueryBuilder<E>) -> QueryBuilder<E>
Apply this scope to a query builder
Auto Trait Implementations§
impl<C> Freeze for TenantScope<C>where
C: Freeze,
impl<C> RefUnwindSafe for TenantScope<C>where
C: RefUnwindSafe,
impl<C> Send for TenantScope<C>
impl<C> Sync for TenantScope<C>
impl<C> Unpin for TenantScope<C>where
C: Unpin,
impl<C> UnsafeUnpin for TenantScope<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for TenantScope<C>where
C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more