pub struct FindManyOperation<E: QueryEngine, M: Model> {
pub extra_projections: Vec<ScalarProjection>,
/* private fields */
}Expand description
Fields§
§extra_projections: Vec<ScalarProjection>Extra scalar-subquery columns appended to the SELECT clause.
Used by relation-aggregate virtual fields (@count, @sum, …).
Implementations§
Source§impl<E: QueryEngine, M: Model + FromRow> FindManyOperation<E, M>
impl<E: QueryEngine, M: Model + FromRow> FindManyOperation<E, M>
Sourcepub fn include(self, spec: IncludeSpec) -> Self
pub fn include(self, spec: IncludeSpec) -> Self
Eager-load a relation alongside the main query.
Each .include() call appends one follow-up SELECT that
fetches the target rows for every parent returned by this
find. Children get stitched onto the parent slice by the
ModelRelationLoader impl emitted by #[derive(Model)].
Sourcepub fn distinct(
self,
columns: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn distinct( self, columns: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Make the query distinct.
Sourcepub fn with_where_input<W: WhereInput<Model = M>>(self, w: W) -> Self
pub fn with_where_input<W: WhereInput<Model = M>>(self, w: W) -> Self
Apply a typed WhereInput. AND-composes with any previously set
filter — same semantics as calling .r#where(...) again.
Sourcepub fn with_include_input<I: IncludeInput<Model = M>>(self, i: I) -> Self
pub fn with_include_input<I: IncludeInput<Model = M>>(self, i: I) -> Self
Apply a typed IncludeInput. Merges into any previously set
includes (later wins on conflicting relation names).
Sourcepub fn with_select_input<S: SelectInput<Model = M>>(self, s: S) -> Self
pub fn with_select_input<S: SelectInput<Model = M>>(self, s: S) -> Self
Apply a typed SelectInput.
Sourcepub fn with_order_by_input<O: OrderByInput<Model = M>>(self, o: O) -> Self
pub fn with_order_by_input<O: OrderByInput<Model = M>>(self, o: O) -> Self
Apply a typed OrderByInput (replaces current).
Source§impl<E, M> FindManyOperation<E, M>
impl<E, M> FindManyOperation<E, M>
Sourcepub fn with_scalar_projection(self, proj: ScalarProjection) -> Self
pub fn with_scalar_projection(self, proj: ScalarProjection) -> Self
Append a scalar-subquery projection to the SELECT list.
Available only on engines that implement
SupportsScalarSubqueryInSelect. SQL backends (Postgres, MySQL,
SQLite, MSSQL, DuckDB, SQLx) all satisfy this bound; MongoDB,
ScyllaDB, and Cassandra do not — calling this method on those
engines is a compile-time error.
Source§impl<E: QueryEngine, M: Model + FromRow> FindManyOperation<E, M>
impl<E: QueryEngine, M: Model + FromRow> FindManyOperation<E, M>
Sourcepub fn build_sql(&self, dialect: &dyn SqlDialect) -> (String, Vec<FilterValue>)
pub fn build_sql(&self, dialect: &dyn SqlDialect) -> (String, Vec<FilterValue>)
Build the SQL query.
Sourcepub async fn exec(self) -> QueryResult<Vec<M>>where
M: Send + 'static + ModelRelationLoader<E>,
pub async fn exec(self) -> QueryResult<Vec<M>>where
M: Send + 'static + ModelRelationLoader<E>,
Execute the query.
After the main SELECT hydrates the parent rows, any pending
.include() specs are dispatched through
ModelRelationLoader::load_relation which issues one
additional SELECT per relation and stitches the children onto
the parent slice.