pub struct EntityManager<'db, S: Schema, M: EntityModel<Schema = S>> { /* private fields */ }Expand description
Schema-bound, model-branded manager for exact entity 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> EntityManager<'db, S, M>where
S: Schema,
M: SubtypeRootModel<Schema = S> + EntityModel<Schema = S>,
impl<'db, S, M> EntityManager<'db, S, M>where
S: Schema,
M: SubtypeRootModel<Schema = S> + EntityModel<Schema = S>,
Sourcepub fn subtypes(&self) -> EntitySubtypeManager<'db, S, M>
pub fn subtypes(&self) -> EntitySubtypeManager<'db, S, M>
Switches only the read scope and result shape to the generated inclusive subtype association; it does not add write operations.
Source§impl<'db, S, M> EntityManager<'db, S, M>
impl<'db, S, M> EntityManager<'db, S, M>
Sourcepub fn filter(&self) -> Result<ProjectedEntityFilter<'db, S, M>>
pub fn filter(&self) -> Result<ProjectedEntityFilter<'db, S, M>>
Start one empty immutable canonical filter for this exact entity model.
Sourcepub fn where_<V>(
&self,
field: FieldToken<M, V>,
operator: ProjectedManagerComparison,
value: &V,
) -> Result<ProjectedEntityFilter<'db, S, M>>where
V: Model<Schema = S> + QueryValued,
pub fn where_<V>(
&self,
field: FieldToken<M, V>,
operator: ProjectedManagerComparison,
value: &V,
) -> Result<ProjectedEntityFilter<'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 entity and returns its 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 a projected exact-model key when one is available; otherwise inserts. For an existing exact row, the supplied create value completely replaces non-key ownership: omitted optional values and empty multivalue collections remove prior ownership. It never reuses a subtype instance, and 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 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 on the exact model at canonical iid, preserves
that IID, and returns its complete freshly hydrated model. Omitted optional values and
empty multivalue collections remove prior ownership.
Sourcepub async fn delete(&self, iid: &str) -> Result<()>
pub async fn delete(&self, iid: &str) -> Result<()>
Deletes only the exact model 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 entity 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 entity 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 model by canonical IID; invalid IIDs are rejected before I/O and a
valid but absent model returns None.
Trait Implementations§
Source§impl<'db, S: Schema, M: EntityModel<Schema = S>> Clone for EntityManager<'db, S, M>
impl<'db, S: Schema, M: EntityModel<Schema = S>> Clone for EntityManager<'db, S, M>
Auto Trait Implementations§
impl<'db, S, M> !RefUnwindSafe for EntityManager<'db, S, M>
impl<'db, S, M> !UnwindSafe for EntityManager<'db, S, M>
impl<'db, S, M> Freeze for EntityManager<'db, S, M>
impl<'db, S, M> Send for EntityManager<'db, S, M>
impl<'db, S, M> Sync for EntityManager<'db, S, M>
impl<'db, S, M> Unpin for EntityManager<'db, S, M>
impl<'db, S, M> UnsafeUnpin for EntityManager<'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