pub trait QueryMethods: Model {
// Provided methods
fn query() -> QueryBuilder<Self>
where Self: Sized { ... }
async fn all(pool: &Pool<Postgres>) -> ModelResult<Vec<Self>>
where Self: Sized { ... }
async fn count(pool: &Pool<Postgres>) -> ModelResult<i64>
where Self: Sized { ... }
async fn where_field<V>(
pool: &Pool<Postgres>,
field: &str,
value: V,
) -> ModelResult<Vec<Self>>
where Self: Sized,
for<'q> V: Send + Sync + 'static + Encode<'q, Postgres> + Type<Postgres> { ... }
async fn first_where<V>(
pool: &Pool<Postgres>,
field: &str,
value: V,
) -> ModelResult<Option<Self>>
where Self: Sized,
for<'q> V: Send + Sync + 'static + Encode<'q, Postgres> + Type<Postgres> { ... }
async fn first(pool: &Pool<Postgres>) -> ModelResult<Option<Self>>
where Self: Sized { ... }
async fn last(pool: &Pool<Postgres>) -> ModelResult<Option<Self>>
where Self: Sized { ... }
}Expand description
Trait providing query operations for model collections
Provided Methods§
Sourcefn query() -> QueryBuilder<Self>where
Self: Sized,
fn query() -> QueryBuilder<Self>where
Self: Sized,
Get a query builder for this model
Sourceasync fn all(pool: &Pool<Postgres>) -> ModelResult<Vec<Self>>where
Self: Sized,
async fn all(pool: &Pool<Postgres>) -> ModelResult<Vec<Self>>where
Self: Sized,
Get all records for this model with proper SQL execution
Sourceasync fn count(pool: &Pool<Postgres>) -> ModelResult<i64>where
Self: Sized,
async fn count(pool: &Pool<Postgres>) -> ModelResult<i64>where
Self: Sized,
Count all records for this model with proper SQL execution
Sourceasync fn where_field<V>(
pool: &Pool<Postgres>,
field: &str,
value: V,
) -> ModelResult<Vec<Self>>
async fn where_field<V>( pool: &Pool<Postgres>, field: &str, value: V, ) -> ModelResult<Vec<Self>>
Find models by a specific field value with proper parameter binding
Sourceasync fn first_where<V>(
pool: &Pool<Postgres>,
field: &str,
value: V,
) -> ModelResult<Option<Self>>
async fn first_where<V>( pool: &Pool<Postgres>, field: &str, value: V, ) -> ModelResult<Option<Self>>
Find the first model by a specific field value
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".