Data API
DataR routes entity operations to persistence backends and shares their
resources inside a context. Queries and streams describe and consume selections.
For application-facing CRUD operations and schema projection, use DataS from
fastsprout.actions. See DataS, DataR, and persistence for
their relationship, or follow the SQLite tutorial
to learn entity operations through a runnable example.
DataR
Bases: Routerable
__init__
__init__(
*,
bus: EventBus | None = None,
dependencies: Sequence[DependsClass] | None = None,
) -> None
__aexit__
async
__aexit__(
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
) -> None
ability
ability[E: Entitieable](
entity: type[E],
) -> DataAbilitable[E, Any, BaseQuery[E, Any], Finalizable]
stream
stream[E: Entitieable, StatementT, ContextT, *Ts](
q: BaseQuery[E, StatementT] | JoinedQueryable[E, ContextT, *Ts],
) -> AsyncEntityStreamable[E] | AsyncJoinedStreamable[*Ts,]
join
Start a lazy inner join; consume it inside this DataR context.
finalize
async
Flush staged intents, then finalize bound backends —
highest priority first.
JoinedStream
Bases: AsyncJoinedStreamable[*Ts,]
Lazy inner joins producing flat, statically typed tuples.
Each step buffers its right source in a hash index, then streams the left rows in order. Duplicate keys produce every matching pair in right-source order. Keys must be hashable; None is an ordinary key. Plans are immutable, but replay requires replayable input sources. Routed sources must share one active DataR context; this is checked during iteration, including sources wrapped in stream transformations.
from_factory
staticmethod
from_factory[*Rs](
factory: Callable[[], AsyncGenerator[tuple[*Rs,], None]],
) -> JoinedStream[*Rs,]
join
join[T](
stream: AsyncIterable[T], *, on: tuple[JoinKey[tuple[*Ts,]], JoinKey[T]]
) -> JoinedStream[*Ts, T]
Append a source, matching keys from the accumulated row and item.
Both key functions can be synchronous or asynchronous, following the same callback conventions as the other data streams.
__aiter__
Return an iterator; close it explicitly when stopping early.
SimpleAsyncEntityStream
SimpleAsyncValueStream
Bases: BaseCommonStream[T], AsyncValueStreamable[T]