Docs / ArchitectureKit 1.0 / Guides / Loading States
Loading States
Some queries need the state of a single subject rather than a view across many, and can read it the same way a command does.
To read the state of a single subject without executing a command, for example to answer a query about it, call the Load function with a context, the store, the state, and the subject:
book, err := architecturekit.Load(context.TODO(), store, bookState, "/books/42")
if err != nil {
// ...
}
Load reads the events exactly the way Execute does before it decides, including FromLatest and the state cache. For a query across many subjects, use a view instead (see Defining Views).