Actions API
See the Actions guide for runnable examples of
function actions, services, CRUD operations, and workflows. The
data guide explains how DataS uses DataR for persistence.
WriteOperation
WriteOperation = Literal[
"create",
"update",
"patch",
"delete",
"bulk_create",
"upsert",
"bulk_upsert",
"update_by_query",
"delete_by_query",
"bulk_update",
"bulk_patch",
"bulk_delete",
]
Action
Bases: Actionable[I, O]
Base for a class action with one typed input and output.
FunctionAction
Service
Bases: ActionGroupable
DataS
Bases: Service, DataSable[E, R, C, U, P, CreateSetting]
CRUD actions using the entity or explicitly configured schemas.
operations
class-attribute
instance-attribute
chunk_size
class-attribute
instance-attribute
__init__
__init__(
entity: type[E] | None = None,
*,
read: SchemaSetting[R] = Undefined,
create: type[C] | CreateSetting,
update: SchemaSetting[U] = Undefined,
patch: SchemaSetting[P] = Undefined,
page: type[Page[R]] | None = None,
dependencies: Sequence[DependsClass] | None = None,
operations: frozenset[DataSOperation] | None = None,
chunk_size: Annotated[int, Ge(1)] | None = None,
) -> None
__init__(
entity: type[E] | None = None,
*,
read: SchemaSetting[R] = Undefined,
create: type[C] | UndefinedType = Undefined,
update: SchemaSetting[U] = Undefined,
patch: SchemaSetting[P] = Undefined,
page: type[Page[R]] | None = None,
dependencies: Sequence[DependsClass] | None = None,
operations: frozenset[DataSOperation] | None = None,
chunk_size: Annotated[int, Ge(1)] | None = None,
) -> None
__init__(
entity: type[E] | None = None,
*,
read: SchemaSetting[R] = Undefined,
create: SchemaSetting[C] = Undefined,
update: SchemaSetting[U] = Undefined,
patch: SchemaSetting[P] = Undefined,
page: type[Page[R]] | None = None,
dependencies: Sequence[DependsClass] | None = None,
operations: frozenset[DataSOperation] | None = None,
chunk_size: Annotated[int, Ge(1)] | None = None,
) -> None
DataSable
Bases: Protocol[E, R, C, U, P, CreateSetting]
bulk_create
bulk_patch
bulk_patch(
entities: AnyIterable[tuple[IdentificatorType, E | P]],
/,
*,
datar: DataR = ...,
) -> AsyncCommonStreamable[R]
bulk_upsert
bulk_delete
bulk_delete(
identifiers: AnyIterable[IdentificatorType], /, *, datar: DataR = ...
) -> LazyAwait[int]
get
async
get[Statement](
identifier: IdentificatorType | BaseQuery[E, Statement], datar: DataR = ...
) -> R | None
exists
async
exists[Statement](
identifier: IdentificatorType | BaseQuery[E, Statement], datar: DataR = ...
) -> bool
count
async
list
async
find_first
async
find_exactly_one
async
find_exactly_one[Statement](
query: BaseQuery[E, Statement] | FieldPredicate[E],
*predicates: FieldPredicate[E],
datar: DataR = ...,
) -> R
find_all
async
Page
Bases: BaseSchema
Workflow
Bases: IteratorActionable[InputT, OutputT], Generic[InputT, OutputT, SourceT]
Yield each step's results and pass each element to the next step.
branches
instance-attribute
branches: (
tuple[
Callable[[InputT], AsyncGenerator[SourceT, None]],
Callable[[SourceT], BranchHandler[OutputT] | None],
]
| None
) = None
__init__
fork
fork[A: Schema, B: Schema](
left: Callable[[OutputT], Awaitable[A]],
right: Callable[[OutputT], Awaitable[B]],
) -> Workflow[InputT, ForkResult[A, B]]
ForkResult
Bases: Schema