pub struct Query<M: Model> { /* private fields */ }Expand description
A live, typed result set over one model’s table: ids only, answered by the engine and
kept current by dependency-gated requeries. Rows stay lazy: fault the ones you show
(Query::materialize, or a list source doing it for you). Clone shares the same set.
Implementations§
Source§impl<M: Model> Query<M>
impl<M: Model> Query<M>
Sourcepub fn error(&self) -> Signal<Option<DbError>>
pub fn error(&self) -> Signal<Option<DbError>>
This query’s last read failure. A failed read preserves its previous result set.
Sourcepub fn refresh(&self)
pub fn refresh(&self)
Explicitly retry a query after a transient read failure (also useful after external SQL).
Sourcepub fn try_ids(&self) -> Result<Vec<ModelId<M>>, DbError>
pub fn try_ids(&self) -> Result<Vec<ModelId<M>>, DbError>
Checked form of ids, for imports and commands that must not mistake failure for absence.
Sourcepub fn try_collect(&self) -> Result<Vec<M>, DbError>
pub fn try_collect(&self) -> Result<Vec<M>, DbError>
A checked snapshot for non-UI work, fetched in batches. UI lists should use the query itself as their row source so they only materialize the visible working set.
Sourcepub fn ids(&self) -> Vec<ModelId<M>>
pub fn ids(&self) -> Vec<ModelId<M>>
The result ids, typed and in query order, as a tracked read: the caller re-runs when the set changes, and only then.
Sourcepub fn count(&self) -> usize
pub fn count(&self) -> usize
The result count, tracked like Query::ids.
Sourcepub fn ids_untracked(&self) -> Vec<ModelId<M>>
pub fn ids_untracked(&self) -> Vec<ModelId<M>>
Untracked snapshot: reactively silent, but still current (pending staleness settles first, like every other read).
Sourcepub fn materialize(&self, range: Range<usize>)
pub fn materialize(&self, range: Range<usize>)
Bring this window of the result into the cache: what a list binding calls for the
rows it is about to show, batched into one SELECT.
Sourcepub fn set_fetch(&self, fetch: Fetch)
pub fn set_fetch(&self, fetch: Fetch)
Swap the fetch (a changed filter or sort): requeries and reloads consumers. No-op when
equal to the current one, so a query_fn closure can re-run cheaply.
Sourcepub fn take_events(&self) -> QueryEvents
pub fn take_events(&self) -> QueryEvents
Drain what changed since the last call: the list source’s feed. Pending staleness settles first, so a drain right after an edit already narrates it.
Trait Implementations§
Auto Trait Implementations§
impl<M> !RefUnwindSafe for Query<M>
impl<M> !Send for Query<M>
impl<M> !Sync for Query<M>
impl<M> !UnwindSafe for Query<M>
impl<M> Freeze for Query<M>
impl<M> Unpin for Query<M>
impl<M> UnsafeUnpin for Query<M>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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