Skip to main content

Query

Struct Query 

Source
pub struct Query { /* private fields */ }
Expand description

Query builder for Automerge documents

Provides a fluent API for building queries with filtering, sorting, and pagination.

Implementations§

Source§

impl Query

Source

pub fn new(store: Arc<AutomergeStore>, collection_name: &str) -> Query

Create a new query for a collection

§Arguments
  • store - AutomergeStore containing the documents
  • collection_name - Name of the collection to query
Source

pub fn where_eq(self, field: &str, value: Value) -> Query

Filter where field equals value

§Example
query.where_eq("operational", Value::Bool(true))
Source

pub fn where_gt(self, field: &str, value: Value) -> Query

Filter where field is greater than value

Source

pub fn where_lt(self, field: &str, value: Value) -> Query

Filter where field is less than value

Source

pub fn where_gte(self, field: &str, value: Value) -> Query

Filter where field is greater than or equal to value

Source

pub fn where_lte(self, field: &str, value: Value) -> Query

Filter where field is less than or equal to value

Source

pub fn where_contains(self, field: &str, value: Value) -> Query

Filter where array field contains value

§Example
query.where_contains("capabilities", Value::String("sensor".into()))
Source

pub fn filter_by_ids(self, ids: &[String]) -> Query

Filter to only documents with IDs in the given set

Used for integrating with spatial indices like GeohashIndex.

§Example
let nearby_ids = geohash_index.find_near(lat, lon)?;
query.filter_by_ids(&nearby_ids)
Source

pub fn order_by(self, field: &str, order: SortOrder) -> Query

Sort results by field

§Example
query.order_by("timestamp", SortOrder::Desc)
Source

pub fn limit(self, n: usize) -> Query

Limit number of results

Source

pub fn offset(self, n: usize) -> Query

Skip first n results (for pagination)

Source

pub fn execute(self) -> Result<Vec<(String, Automerge)>, Error>

Execute the query and return matching documents

Returns (doc_id, Automerge) tuples for all matching documents.

Source

pub fn execute_ids(self) -> Result<Vec<String>, Error>

Execute and return only document IDs

Source

pub fn execute_json(self) -> Result<Vec<(String, Value)>, Error>

Execute the query and return matching documents as JSON values.

Source

pub fn count(self) -> Result<usize, Error>

Count matching documents (without loading full documents)

Auto Trait Implementations§

§

impl Freeze for Query

§

impl !RefUnwindSafe for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnsafeUnpin for Query

§

impl !UnwindSafe for Query

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more