pub struct RelationManager<'db, S: Schema, M: RelationModel<Schema = S>> { /* private fields */ }Expand description
Schema-bound, model-branded manager for exact relation operations. Exact reads and writes exclude subtypes; methods return client input/schema-validation, database/transaction/close, or hydration/model-validation errors as applicable.
Implementations§
Source§impl<'db, S, M> RelationManager<'db, S, M>
impl<'db, S, M> RelationManager<'db, S, M>
Sourcepub fn filter(&self) -> Result<ProjectedRelationFilter<'db, S, M>>
pub fn filter(&self) -> Result<ProjectedRelationFilter<'db, S, M>>
Start one empty immutable canonical filter for this exact relation model.
Sourcepub fn where_<V>(
&self,
field: FieldToken<M, V>,
operator: ProjectedManagerComparison,
value: &V,
) -> Result<ProjectedRelationFilter<'db, S, M>>where
V: Model<Schema = S> + QueryValued,
pub fn where_<V>(
&self,
field: FieldToken<M, V>,
operator: ProjectedManagerComparison,
value: &V,
) -> Result<ProjectedRelationFilter<'db, S, M>>where
V: Model<Schema = S> + QueryValued,
Start a canonical filter with one exact generated field comparison.
Sourcepub fn add_hook(&mut self, hook: Arc<dyn LifecycleHook>) -> &mut Self
pub fn add_hook(&mut self, hook: Arc<dyn LifecycleHook>) -> &mut Self
Register one generated-model lifecycle hook on this manager. Pre-hooks run in registration order and post-hooks in reverse order.
Sourcepub async fn insert(&self, input: M::Create) -> Result<M>
pub async fn insert(&self, input: M::Create) -> Result<M>
Inserts one exact relation with its complete active role players and returns the complete freshly hydrated model. Errors may be input/schema validation, database/transaction/close, or model hydration errors.
Sourcepub async fn put(&self, input: M::Create) -> Result<M>
pub async fn put(&self, input: M::Create) -> Result<M>
Uses the projected exact-model key when one usable key is carried; otherwise inserts. For an existing exact row, the supplied create value completely replaces non-key ownership and the complete effective active-role player set while preserving the exact IID and keys. It returns a complete freshly hydrated model.
Sourcepub async fn insert_many(&self, inputs: Vec<M::Create>) -> Result<Vec<M>>
pub async fn insert_many(&self, inputs: Vec<M::Create>) -> Result<Vec<M>>
Inserts each item and returns complete freshly hydrated models in input order, or one error for the whole call with no partial result vector.
Sourcepub async fn put_many(&self, inputs: Vec<M::Create>) -> Result<Vec<M>>
pub async fn put_many(&self, inputs: Vec<M::Create>) -> Result<Vec<M>>
Applies the per-item Self::put key-or-insert rule, including complete replacement
of non-key ownership and active role players for existing exact rows, returning
complete freshly hydrated models in input order, or one error for the whole call with
no partial vector.
Sourcepub async fn update(&self, iid: &str, input: M::Create) -> Result<M>
pub async fn update(&self, iid: &str, input: M::Create) -> Result<M>
Completely replaces non-key ownership and the complete effective active-role player
set on the exact relation at canonical iid, preserves that IID and its keys, and
returns its complete freshly hydrated model.
Sourcepub async fn delete(&self, iid: &str) -> Result<()>
pub async fn delete(&self, iid: &str) -> Result<()>
Deletes only the exact relation at canonical iid; subtype instances are not
targeted.
Sourcepub async fn update_many(
&self,
inputs: Vec<(String, M::Create)>,
) -> Result<Vec<M>>
pub async fn update_many( &self, inputs: Vec<(String, M::Create)>, ) -> Result<Vec<M>>
Atomically replaces each exact relation identified by its canonical IID and returns complete freshly hydrated models in input order. Every input and pre-hook completes before database work begins; any write or hydration failure rolls back the whole batch.
Sourcepub async fn delete_many(&self, iids: &[String]) -> Result<()>
pub async fn delete_many(&self, iids: &[String]) -> Result<()>
Atomically deletes every exact relation at the supplied canonical IIDs. All IIDs and pre-hooks are accepted before database work begins; any write failure rolls back the whole batch, and post-hook failures do not change the committed result.
Sourcepub async fn get_by_iid(&self, iid: &str) -> Result<Option<M>>
pub async fn get_by_iid(&self, iid: &str) -> Result<Option<M>>
Reads one exact coalesced relation by canonical IID; invalid IIDs are rejected before
I/O and a valid but absent relation returns None.
Source§impl<'db, S, M> RelationManager<'db, S, M>where
S: Schema,
M: SubtypeRootModel<Schema = S> + RelationModel<Schema = S>,
impl<'db, S, M> RelationManager<'db, S, M>where
S: Schema,
M: SubtypeRootModel<Schema = S> + RelationModel<Schema = S>,
Sourcepub fn subtypes(&self) -> RelationSubtypeManager<'db, S, M>
pub fn subtypes(&self) -> RelationSubtypeManager<'db, S, M>
Switches only the read scope and result shape to the generated inclusive subtype association; it does not add write operations.
Trait Implementations§
Source§impl<'db, S: Schema, M: RelationModel<Schema = S>> Clone for RelationManager<'db, S, M>
impl<'db, S: Schema, M: RelationModel<Schema = S>> Clone for RelationManager<'db, S, M>
Auto Trait Implementations§
impl<'db, S, M> !RefUnwindSafe for RelationManager<'db, S, M>
impl<'db, S, M> !UnwindSafe for RelationManager<'db, S, M>
impl<'db, S, M> Freeze for RelationManager<'db, S, M>
impl<'db, S, M> Send for RelationManager<'db, S, M>
impl<'db, S, M> Sync for RelationManager<'db, S, M>
impl<'db, S, M> Unpin for RelationManager<'db, S, M>
impl<'db, S, M> UnsafeUnpin for RelationManager<'db, S, M>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request