Skip to content

Queries

A screen needs a list, a detail view, or a dashboard—not another hand-written API client. Arc lets you declare the read, expose it through HTTP, and generate a typed TypeScript proxy for the frontend.

Queries read application state. That can be a MongoDB document, an EF Core entity, data from a service, or an in-memory model. Arc queries do not require Chronicle or event sourcing. A database query or MongoDB Observe() call is not a Chronicle projection. If your application optionally uses Chronicle, its projected read models can be queried too; see Chronicle integration.

StyleWhat you writeChoose it when
Model-boundStatic query method on the [ReadModel] type it returnsYou want the query next to its data shape with minimal endpoint boilerplate
Controller-basedMVC GET actionYou need MVC route-value/DTO binding, filters, or HTTP response control

The two paths share result rendering but not all binding, validation, or authorization behavior. Start with the model-bound example, then use the controller path deliberately where its contract fits better.

GET / QUERY / subscribe

one result

streamed results

Client

Arc endpoint

Query method

Application state

Optional observable producer

ModeBehaviorUse it for
Request/responseRead once through GET or generated HTTP QUERYOne-off reads and reports
ObservableSubscribe to a producer over SSE/WebSocketLists or dashboards that should stay current

An observable query needs a producer that detects changes; a return type alone does not watch your database. Arc’s MongoDB integration supplies Observe(). Other providers need their own observation mechanism. An update may follow a command changing database state directly, or an optional Chronicle projection updating it.

  1. Declare a model-bound read, then add arguments.
  2. Apply validation and authorization, including their current limitations.
  3. Read the QueryResult contract and add paging.
  4. Expose observable updates and understand subscription disposal.
  5. For advanced delivery, use the hub protocol, change streams, and emission guards.

Read-model interception transforms supported result paths, but currently excludes observable HTTP snapshots. Query health helps diagnose hub subscriptions but exposes sensitive telemetry unless you restrict it. Use cURL workflows to distinguish a snapshot from a live stream.

A successful backend proxy-generation build supplies typed client declarations. Use the generated query’s hook and result state instead of maintaining a separate transport model. Continue with queries in React and proxy generation.