Skip to content

Read model inspection with Cratis CLI

A read model is projected state built from events by an observer. Chronicle maintains read model instances in storage and updates them as new events arrive. Each instance is identified by a key — typically an event source ID — and contains a document that represents the current state of that entity.

Lists all read model definitions registered in the specified event store and namespace.

Terminal window
cratis chronicle read-models list
Flag Description
-e, --event-store <NAME> Event store to inspect. Defaults to the active context’s event store, then default.
-n, --namespace <NAME> Accepted but has no effect: read model definitions belong to the event store, not a namespace.

The table includes a Queryable column (Yes/No) indicating whether the read model stores state server-side and can be inspected with get or instances. Client-owned read models show No — their state lives in the client application and cannot be retrieved through the Chronicle server. The JSON output includes a queryable boolean field for programmatic use.

Use --output plain when enumerating read models.

Terminal window
cratis chronicle read-models list --output plain

List all read models:

Terminal window
cratis chronicle read-models list

Get read model names for scripting:

Terminal window
cratis chronicle read-models list -q

Lists the stored instances of a read model, with pagination support.

Terminal window
cratis chronicle read-models instances <READ_MODEL>
Argument Description
READ_MODEL The read model name. Use read-models list -q to retrieve names.
Flag Description
-e, --event-store <NAME> Event store to inspect. Defaults to the active context’s event store, then default.
-n, --namespace <NAME> Namespace to inspect. Defaults to the active context’s namespace, then Default.
--page <NUMBER> Zero-based page index. Defaults to 0.
--page-size <COUNT> Number of instances per page. Defaults to 20.

List the first page of instances:

Terminal window
cratis chronicle read-models instances UserProfile

List the second page with a larger page size:

Terminal window
cratis chronicle read-models instances UserProfile --page 1 --page-size 50

Gets a single read model instance by key.

Terminal window
cratis chronicle read-models get <READ_MODEL> <KEY>
Argument Description
READ_MODEL The read model name.
KEY The instance key, typically an event source ID.
Flag Description
-e, --event-store <NAME> Event store to inspect. Defaults to the active context’s event store, then default.
-n, --namespace <NAME> Namespace to inspect. Defaults to the active context’s namespace, then Default.
--sequence <NAME> Event sequence associated with the read model. Defaults to the event log.

Get a read model instance:

Terminal window
cratis chronicle read-models get UserProfile user-42

Get the full document as JSON:

Terminal window
cratis chronicle read-models get UserProfile user-42 -o json

Lists the replay history (occurrences) of a read model type, optionally for a specific generation: one row each time it was built or rebuilt, with the observer, when it occurred, the read model type and generation, and the container and revert container names. It does not return a count.

Terminal window
cratis chronicle read-models occurrences <READ_MODEL_TYPE>
Argument Description
READ_MODEL_TYPE The read model type name.
Flag Description
-e, --event-store <NAME> Event store to inspect. Defaults to the active context’s event store, then default.
-n, --namespace <NAME> Namespace to inspect. Defaults to the active context’s namespace, then Default.
--generation <NUMBER> Read model generation to list occurrences for. Defaults to 1.

List the replay history of a read model:

Terminal window
cratis chronicle read-models occurrences UserProfile

List the replay history of a specific generation:

Terminal window
cratis chronicle read-models occurrences UserProfile --generation 2

Lists or retrieves snapshots for a specific read model instance. Snapshots are point-in-time captures of a read model’s state, including the sequence number at which the snapshot was taken.

Terminal window
cratis chronicle read-models snapshots <READ_MODEL> <KEY>
Argument Description
READ_MODEL The read model name.
KEY The instance key, typically an event source ID.
Flag Description
-e, --event-store <NAME> Event store to inspect. Uses the explicit option, then the active context’s event store, then default.
-n, --namespace <NAME> Namespace to inspect. Uses the explicit option, then the active context’s namespace, then Default.

List snapshots for an instance:

Terminal window
cratis chronicle read-models snapshots UserProfile user-42

Get snapshot details including full documents and event metadata:

Terminal window
cratis chronicle read-models snapshots UserProfile user-42 -o json