pub trait CounterCache: Record {
// Required method
fn counter_cache_columns() -> &'static [(&'static str, &'static str)];
// Provided methods
async fn increment_counter(
column: &str,
id: i64,
db: &DatabaseConnection,
) -> Result<(), RecordError> { ... }
async fn decrement_counter(
column: &str,
id: i64,
db: &DatabaseConnection,
) -> Result<(), RecordError> { ... }
}Expand description
Counter cache helpers for record types.
Required Methods§
Sourcefn counter_cache_columns() -> &'static [(&'static str, &'static str)]
fn counter_cache_columns() -> &'static [(&'static str, &'static str)]
Returns the available counter cache columns as (column, association) pairs.
Provided Methods§
Sourceasync fn increment_counter(
column: &str,
id: i64,
db: &DatabaseConnection,
) -> Result<(), RecordError>
async fn increment_counter( column: &str, id: i64, db: &DatabaseConnection, ) -> Result<(), RecordError>
Increments a counter cache column for the record identified by id.
Sourceasync fn decrement_counter(
column: &str,
id: i64,
db: &DatabaseConnection,
) -> Result<(), RecordError>
async fn decrement_counter( column: &str, id: i64, db: &DatabaseConnection, ) -> Result<(), RecordError>
Decrements a counter cache column for the record identified by id.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.