pub struct FindFirstOperation<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> FindFirstOperation<E, M>
impl<E: QueryEngine, M: Model + FromRow> FindFirstOperation<E, M>
Sourcepub fn include(self, spec: IncludeSpec) -> Self
pub fn include(self, spec: IncludeSpec) -> Self
Eager-load a relation alongside the first-match lookup.
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> FindFirstOperation<E, M>
impl<E, M> FindFirstOperation<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> FindFirstOperation<E, M>
impl<E: QueryEngine, M: Model + FromRow> FindFirstOperation<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<Option<M>>where
M: Send + 'static + ModelRelationLoader<E>,
pub async fn exec(self) -> QueryResult<Option<M>>where
M: Send + 'static + ModelRelationLoader<E>,
Execute the query and return an optional result.
Sourcepub async fn exec_required(self) -> QueryResult<M>where
M: Send + 'static + ModelRelationLoader<E>,
pub async fn exec_required(self) -> QueryResult<M>where
M: Send + 'static + ModelRelationLoader<E>,
Execute the query and error if not found.