pub struct DbSession<C: CanisterKind> { /* private fields */ }Expand description
DbSession
Session-scoped database handle with policy (debug, metrics) and execution routing.
Implementations§
Source§impl<C: CanisterKind> DbSession<C>
impl<C: CanisterKind> DbSession<C>
pub const fn new(db: Db<C>) -> Self
pub const fn debug(self) -> Self
pub const fn metrics_sink(self, sink: &'static dyn MetricsSink) -> Self
pub const fn load<E>(&self) -> FluentLoadQuery<'_, E>where
E: EntityKind<Canister = C>,
pub const fn load_with_consistency<E>(
&self,
consistency: ReadConsistency,
) -> FluentLoadQuery<'_, E>where
E: EntityKind<Canister = C>,
pub fn delete<E>(&self) -> FluentDeleteQuery<'_, E>where
E: EntityKind<Canister = C>,
pub fn delete_with_consistency<E>(
&self,
consistency: ReadConsistency,
) -> FluentDeleteQuery<'_, E>where
E: EntityKind<Canister = C>,
pub fn execute_query<E>(
&self,
query: &Query<E>,
) -> Result<Response<E>, QueryError>where
E: EntityKind<Canister = C> + EntityValue,
pub fn insert<E>(&self, entity: E) -> Result<WriteResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Sourcepub fn insert_many_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
pub fn insert_many_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Insert a single-entity-type batch atomically in one commit window.
If any item fails pre-commit validation, no row in the batch is persisted.
This API is not a multi-entity transaction surface.
Sourcepub fn insert_many_non_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
pub fn insert_many_non_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Insert a batch with explicitly non-atomic semantics.
WARNING: fail-fast and non-atomic. Earlier inserts may commit before an error.
pub fn replace<E>(&self, entity: E) -> Result<WriteResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Sourcepub fn replace_many_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
pub fn replace_many_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Replace a single-entity-type batch atomically in one commit window.
If any item fails pre-commit validation, no row in the batch is persisted.
This API is not a multi-entity transaction surface.
Sourcepub fn replace_many_non_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
pub fn replace_many_non_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Replace a batch with explicitly non-atomic semantics.
WARNING: fail-fast and non-atomic. Earlier replaces may commit before an error.
pub fn update<E>(&self, entity: E) -> Result<WriteResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Sourcepub fn update_many_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
pub fn update_many_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Update a single-entity-type batch atomically in one commit window.
If any item fails pre-commit validation, no row in the batch is persisted.
This API is not a multi-entity transaction surface.
Sourcepub fn update_many_non_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
pub fn update_many_non_atomic<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<WriteBatchResponse<E>, InternalError>where
E: EntityKind<Canister = C> + EntityValue,
Update a batch with explicitly non-atomic semantics.
WARNING: fail-fast and non-atomic. Earlier updates may commit before an error.