pub struct Select<T: SurrealRecord> { /* private fields */ }Expand description
A SELECT statement builder: projections, WHERE, ORDER BY, LIMIT,
START, FETCH, GROUP BY/GROUP ALL, count(), and the modifiers
VALUE/OMIT/SPLIT/WITH/TIMEOUT/EXPLAIN.
Implementations§
Source§impl<T: SurrealRecord> Select<T>
impl<T: SurrealRecord> Select<T>
pub fn filter(self, expr: impl DynExpr + 'static) -> Self
Sourcepub fn with_path(self, path: Path, alias: &'static str) -> Self
pub fn with_path(self, path: Path, alias: &'static str) -> Self
Add a <path> AS <alias> graph-traversal projection to the select list.
Appends to any existing projections, so select(T::all()).with_path(p, "x")
renders SELECT *, <path> AS x (a * is emitted only when the list is
otherwise empty).
pub fn limit(self, n: u32) -> Self
pub fn start(self, n: u32) -> Self
pub fn fetch(self, field: impl Into<String>) -> Self
pub fn group_by<C: DynExpr>(self, col: C) -> Self
Sourcepub fn count_as(self, alias: &'static str) -> Self
pub fn count_as(self, alias: &'static str) -> Self
Alias for the count() projection: SELECT count() AS <alias>.
Sourcepub fn value(self) -> Self
pub fn value(self) -> Self
SELECT VALUE … — return bare values instead of field-wrapping objects.
Pair with a single projection (e.g. project(vec![col("name")]).value()).
Sourcepub fn omit(self, field: impl Into<String>) -> Self
pub fn omit(self, field: impl Into<String>) -> Self
OMIT <field> — exclude a field from a SELECT *.
Sourcepub fn split(self, field: impl Into<String>) -> Self
pub fn split(self, field: impl Into<String>) -> Self
SPLIT <field> — fan one row out into multiple rows by an array field.
Sourcepub fn with_index<I, S>(self, indexes: I) -> Self
pub fn with_index<I, S>(self, indexes: I) -> Self
WITH INDEX <a, b> — force the planner to use the named index(es).
Sourcepub fn with_no_index(self) -> Self
pub fn with_no_index(self) -> Self
WITH NOINDEX — force a table scan (ignore indexes).
Sourcepub fn timeout(self, duration: impl Into<String>) -> Self
pub fn timeout(self, duration: impl Into<String>) -> Self
TIMEOUT <duration> — abort the query after the given duration (e.g. "5s").
Sourcepub fn from_subquery(self, sub: Select<T>) -> Self
pub fn from_subquery(self, sub: Select<T>) -> Self
SELECT … FROM (<subquery>) — read from a subquery instead of the base
table. The subquery (a Select<T> of the same record type) renders
parenthesized in place of the table name.
Sourcepub fn explain_full(self) -> Self
pub fn explain_full(self) -> Self
EXPLAIN FULL — return the query plan with execution detail.
pub fn order_by<C: DynExpr>(self, col: C, dir: Order) -> Self
pub fn order_asc<C: DynExpr>(self, col: C) -> Self
pub fn order_desc<C: DynExpr>(self, col: C) -> Self
pub fn to_surrealql(&self) -> String
Sourcepub fn to_surrealql_with_params(&self) -> (String, BTreeMap<String, Value>)
pub fn to_surrealql_with_params(&self) -> (String, BTreeMap<String, Value>)
Render the statement with $param placeholders instead of inlined
literals, returning the SQL string and a map of parameter name to value.
Literal values become numbered $p0, $p1, …; explicit Param
wrappers use their declared name.
Trait Implementations§
Source§impl<T: SurrealRecord> Debug for Select<T>
impl<T: SurrealRecord> Debug for Select<T>
Source§impl<T: SurrealRecord> Display for Select<T>
impl<T: SurrealRecord> Display for Select<T>
Source§impl<T: SurrealRecord> DynExpr for Select<T>
A Select is usable as an expression — rendered parenthesized — so it can be
embedded as a subquery: a scalar/IN operand in a WHERE, a projection, or a
SET/FROM value. Params from the subquery merge into the parent’s map.
impl<T: SurrealRecord> DynExpr for Select<T>
A Select is usable as an expression — rendered parenthesized — so it can be
embedded as a subquery: a scalar/IN operand in a WHERE, a projection, or a
SET/FROM value. Params from the subquery merge into the parent’s map.
Source§fn render_dyn(&self, buf: &mut String)
fn render_dyn(&self, buf: &mut String)
buf with all values inlined.Auto Trait Implementations§
impl<T> !RefUnwindSafe for Select<T>
impl<T> !UnwindSafe for Select<T>
impl<T> Freeze for Select<T>
impl<T> Send for Select<T>
impl<T> Sync for Select<T>
impl<T> Unpin for Select<T>where
T: Unpin,
impl<T> UnsafeUnpin for Select<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more