Skip to main content

RelationManager

Struct RelationManager 

Source
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>
where S: Schema, M: RelationModel<Schema = S> + CompleteModel,

Source

pub fn filter(&self) -> Result<ProjectedRelationFilter<'db, S, M>>

Start one empty immutable canonical filter for this exact relation model.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn delete(&self, iid: &str) -> Result<()>

Deletes only the exact relation at canonical iid; subtype instances are not targeted.

Source

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.

Source

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.

Source

pub async fn count(&self) -> Result<u64>

Counts only exact relations, excluding subtypes.

Source

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

pub async fn all(&self) -> Result<Vec<M>>

Reads all exact coalesced relations in application result order, excluding subtypes; each result is a complete hydrated model.

Source§

impl<'db, S, M> RelationManager<'db, S, M>
where S: Schema, M: SubtypeRootModel<Schema = S> + RelationModel<Schema = S>,

Source

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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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>
where &'db Database<S>: Freeze, PhantomData<M>: Freeze,

§

impl<'db, S, M> Send for RelationManager<'db, S, M>
where &'db Database<S>: Send, PhantomData<M>: Send,

§

impl<'db, S, M> Sync for RelationManager<'db, S, M>
where &'db Database<S>: Sync, PhantomData<M>: Sync,

§

impl<'db, S, M> Unpin for RelationManager<'db, S, M>
where &'db Database<S>: Unpin, PhantomData<M>: Unpin,

§

impl<'db, S, M> UnsafeUnpin for RelationManager<'db, S, M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more