pub struct Path { /* private fields */ }Expand description
A graph-traversal expression — e.g. ->wrote->post, <-wrote<-user, or a
multi-hop chain with an optional .field/.* accessor at the end.
A Path is a DynExpr, so it works anywhere the builder takes an
expression: as a SELECT projection (Projection::aliased(path, "posts")),
inside a WHERE filter, or as a SET value. With no start it is relative to
the statement’s FROM table; Path::from_record anchors it to a record.
// ->wrote->post.title AS titles
let p = Path::out::<Wrote>().to::<Post>().field("title");
Post::table().project(vec![Projection::aliased(p, "titles")]);Implementations§
Source§impl Path
impl Path
Sourcepub fn out<E: SurrealEdge>() -> Self
pub fn out<E: SurrealEdge>() -> Self
Start an outgoing hop over edge E — ->edge.
Sourcepub fn inn<E: SurrealEdge>() -> Self
pub fn inn<E: SurrealEdge>() -> Self
Start an incoming hop over edge E — <-edge.
Sourcepub fn both<E: SurrealEdge>() -> Self
pub fn both<E: SurrealEdge>() -> Self
Start a bidirectional hop over edge E — <->edge.
Sourcepub fn out_edge(edge: &'static str) -> Self
pub fn out_edge(edge: &'static str) -> Self
Start an outgoing hop over a raw edge name — ->edge.
Sourcepub fn in_edge(edge: &'static str) -> Self
pub fn in_edge(edge: &'static str) -> Self
Start an incoming hop over a raw edge name — <-edge.
Sourcepub fn both_edge(edge: &'static str) -> Self
pub fn both_edge(edge: &'static str) -> Self
Start a bidirectional hop over a raw edge name — <->edge.
Sourcepub fn from_record<V: SurrealQL>(self, start: V) -> Self
pub fn from_record<V: SurrealQL>(self, start: V) -> Self
Anchor an existing path to a starting record literal — <record><path>
(e.g. user:tobie->wrote->post). Pass a Thing.
Sourcepub fn from_expr(self, start: impl DynExpr + 'static) -> Self
pub fn from_expr(self, start: impl DynExpr + 'static) -> Self
Anchor an existing path to a starting expression — e.g. a
RecordLink (type::record('user', $id)->wrote->post).
Sourcepub fn to<T: SurrealRecord>(self) -> Self
pub fn to<T: SurrealRecord>(self) -> Self
Constrain the destination of the most recent hop to table T — ->edge->table.
Sourcepub fn to_table(self, table: &'static str) -> Self
pub fn to_table(self, table: &'static str) -> Self
Constrain the destination of the most recent hop to a raw table name.
Sourcepub fn where_(self, expr: impl DynExpr + 'static) -> Self
pub fn where_(self, expr: impl DynExpr + 'static) -> Self
Filter the most recent hop’s edge — ->(edge WHERE <expr>).
Sourcepub fn then_out<E: SurrealEdge>(self) -> Self
pub fn then_out<E: SurrealEdge>(self) -> Self
Chain another outgoing hop over edge E.
Sourcepub fn then_in<E: SurrealEdge>(self) -> Self
pub fn then_in<E: SurrealEdge>(self) -> Self
Chain another incoming hop over edge E.
Sourcepub fn then_both<E: SurrealEdge>(self) -> Self
pub fn then_both<E: SurrealEdge>(self) -> Self
Chain another bidirectional hop over edge E.
Sourcepub fn then_out_edge(self, edge: &'static str) -> Self
pub fn then_out_edge(self, edge: &'static str) -> Self
Chain another hop over a raw edge name, outgoing.
Sourcepub fn then_in_edge(self, edge: &'static str) -> Self
pub fn then_in_edge(self, edge: &'static str) -> Self
Chain another hop over a raw edge name, incoming.
Sourcepub fn recurse_all(self) -> Self
pub fn recurse_all(self) -> Self
Repeat the path recursively, unbounded — @.{..}<path>. Combine with
from_record to anchor the recursion at a record
(person:tobie.{..}->knows->person).
Sourcepub fn recurse_up_to(self, max: u32) -> Self
pub fn recurse_up_to(self, max: u32) -> Self
Recurse up to max hops — @.{..max}<path>.
Sourcepub fn recurse_range(self, min: u32, max: u32) -> Self
pub fn recurse_range(self, min: u32, max: u32) -> Self
Recurse between min and max hops — @.{min..max}<path>.
Sourcepub fn recurse_exact(self, n: u32) -> Self
pub fn recurse_exact(self, n: u32) -> Self
Recurse exactly n hops — @.{n}<path>.
Sourcepub fn contains<V: SurrealQL>(self, value: V) -> ContainsExpr
pub fn contains<V: SurrealQL>(self, value: V) -> ContainsExpr
<path> CONTAINS <value> — e.g. membership test over a traversed list.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Path
impl !UnwindSafe for Path
impl Freeze for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnsafeUnpin for Path
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