Finding Records

The Store provides functions for retrieving records of a single type.

See Fetching Data in the routing guide for how to obtain a reference to the application-wide store.

Retrieving a Single Record

Use Store::find_record() to retrieve a record by its type and ID.

use crate::models::customer::Customer;

let customer: Customer = store.find_record("customer", "123", None).await?;

Use Store::peek_record() to retrieve a record by its type and ID, without making a network request. This will return the record only if it is already present in the store's cache:

let maybe_customer: Option<Customer> = store.peek_record("customer", "123")?;

Retrieving Multiple Records

Use Store::find_all() to retrieve all of the records for a given type:

use crate::models::customer::Customer;

let customers: Vec<Customer> = store.find_all("customer", None).await?;

Use Store::peek_all() to retrieve all of the records for a given type that are already loaded in the store, without making a network request:

use crate::models::customer::Customer;

let customers: Vec<Customer> = store.peek_all("customer")?;

Querying for Multiple Records

Use Store::query() to query for records that meet certain criteria.

use crate::models::customer::Customer;
use serde_json::json;

let customers: Vec<Customer> = store.query("customer", json!({
    "filter": {
        "name": "Acme Widgets",
    },
})).await?;

©2026 Megalithic LLC | Website | GitLab | Contact