Skip to main content

CounterCache

Trait CounterCache 

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

Source

fn counter_cache_columns() -> &'static [(&'static str, &'static str)]

Returns the available counter cache columns as (column, association) pairs.

Provided Methods§

Source

async fn increment_counter( column: &str, id: i64, db: &DatabaseConnection, ) -> Result<(), RecordError>

Increments a counter cache column for the record identified by id.

Source

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.

Implementors§