Skip to main content

count_in

Function count_in 

Source
pub async fn count_in<M: Model>(
    ex: &mut dyn Executor,
    query: impl IntoStatement<Returning = List<M>>,
) -> Result<u64>
Expand description

How many rows query holds, counted through ex: inside the transaction a record fn or a hook received, so the count sees the rows the write has made so far and a limit check holds against concurrent writes the isolation level orders. Reads 0 where Toasty answers no value, as count does.

let projects = db::count_in(ex, Project::filter(Project::fields().team_id().eq(team))).await?;
Ok(projects < 10)

ยงErrors

The database failing the count, and a declaration failure for a statement that writes, such as an insert, which has no rows to count.