Count number of selected result

A naive way to approach this problem is to fetch the selection from the database, have it converted to a vector, then check the length of the vector. This is however, very expensive, and SeaORM provides a PaginatorTrait::count method to count without actually fetching it. PaginatorTrait is implemented by Select, SelectTwo, Selector, and SelectorRaw. So one can get the count by first creating such object, then call the method. For example:

#![allow(unused)]
fn main() {
// Create a Select object
let selection = table::Entity::find();

// Count the number of selection
selection.count(db).await?
}