pub struct DbSession<C: CanisterKind> { /* private fields */ }Expand description
DbSession Database handle plus a debug flag that controls executor verbosity.
Implementations§
Source§impl<C: CanisterKind> DbSession<C>
impl<C: CanisterKind> DbSession<C>
Sourcepub const fn load<E>(&self) -> LoadExecutor<E>where
E: EntityKind<Canister = C>,
pub const fn load<E>(&self) -> LoadExecutor<E>where
E: EntityKind<Canister = C>,
Get a LoadExecutor for building and executing queries that read entities.
Sourcepub const fn save<E>(&self) -> SaveExecutor<E>where
E: EntityKind<Canister = C>,
pub const fn save<E>(&self) -> SaveExecutor<E>where
E: EntityKind<Canister = C>,
Get a SaveExecutor for inserting or updating entities.
Normally you will use the higher-level create/replace/update shortcuts instead.
Sourcepub const fn upsert<E>(&self) -> UpsertExecutor<E>
pub const fn upsert<E>(&self) -> UpsertExecutor<E>
Get an UpsertExecutor for inserting or updating by a unique index.
Sourcepub const fn delete<E>(&self) -> DeleteExecutor<E>where
E: EntityKind<Canister = C>,
pub const fn delete<E>(&self) -> DeleteExecutor<E>where
E: EntityKind<Canister = C>,
Get a DeleteExecutor for deleting entities by key or query.
Sourcepub fn insert<E>(&self, entity: E) -> Result<E, Error>where
E: EntityKind<Canister = C>,
pub fn insert<E>(&self, entity: E) -> Result<E, Error>where
E: EntityKind<Canister = C>,
Insert a new entity, returning the stored value.
Sourcepub fn insert_many<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<Vec<E>, Error>where
E: EntityKind<Canister = C>,
pub fn insert_many<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<Vec<E>, Error>where
E: EntityKind<Canister = C>,
Insert multiple entities, returning stored values.
Sourcepub fn replace<E>(&self, entity: E) -> Result<E, Error>where
E: EntityKind<Canister = C>,
pub fn replace<E>(&self, entity: E) -> Result<E, Error>where
E: EntityKind<Canister = C>,
Replace an existing entity or insert it if it does not yet exist.
Sourcepub fn replace_many<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<Vec<E>, Error>where
E: EntityKind<Canister = C>,
pub fn replace_many<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<Vec<E>, Error>where
E: EntityKind<Canister = C>,
Replace multiple entities, inserting if missing.
Sourcepub fn update<E>(&self, entity: E) -> Result<E, Error>where
E: EntityKind<Canister = C>,
pub fn update<E>(&self, entity: E) -> Result<E, Error>where
E: EntityKind<Canister = C>,
Partially update an existing entity.
Sourcepub fn update_many<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<Vec<E>, Error>where
E: EntityKind<Canister = C>,
pub fn update_many<E>(
&self,
entities: impl IntoIterator<Item = E>,
) -> Result<Vec<E>, Error>where
E: EntityKind<Canister = C>,
Partially update multiple existing entities.
Sourcepub fn insert_view<E>(&self, view: E::ViewType) -> Result<E::ViewType, Error>where
E: EntityKind<Canister = C>,
pub fn insert_view<E>(&self, view: E::ViewType) -> Result<E::ViewType, Error>where
E: EntityKind<Canister = C>,
Insert a new view value for an entity.
Sourcepub fn replace_view<E>(&self, view: E::ViewType) -> Result<E::ViewType, Error>where
E: EntityKind<Canister = C>,
pub fn replace_view<E>(&self, view: E::ViewType) -> Result<E::ViewType, Error>where
E: EntityKind<Canister = C>,
Replace an existing view or insert it if it does not yet exist.
Sourcepub fn update_view<E>(&self, view: E::ViewType) -> Result<E::ViewType, Error>where
E: EntityKind<Canister = C>,
pub fn update_view<E>(&self, view: E::ViewType) -> Result<E::ViewType, Error>where
E: EntityKind<Canister = C>,
Partially update an existing view.