Reference
Generated CRUD API¶
The CRUD guide explains action generation, access policies, ownership, schema requirements and route replacement.
hinoki.resources.crud ¶
crud(
model: type[Model],
*,
path: str,
read: type[Schema],
create: type[Schema] | None = None,
update: type[Schema] | None = None,
delete: bool = False,
access: Access | CrudAccess | None = None,
public_writes: bool = False,
owner: str = "",
identity_key: Callable[[Any], Any] = attrgetter("id"),
assign: Mapping[str, Callable[[Any], Any]]
| None = None,
pagination: PageNumberPagination = PageNumberPagination(),
omit: tuple[str, ...] = (),
name: str | None = None,
) -> CrudDeclaration
Declare generated CRUD for model.
app.include(crud(...)) mounts the generated actions; @crud(...) on a
class adds the hooks (get_queryset, to_schema, written_queryset,
store, change, remove) and handwritten actions.
A single Access protects every action; CrudAccess sets them apart.
name= names the generated class ("ArchiveCrud") or its module and
class ("notes.apps.archive.ArchiveCrud") that rules and MCP patterns match.
hinoki.resources.CrudAccess
dataclass
¶
CrudAccess(
*,
default: Access | None = None,
list: Access | Unset | None = UNSET,
retrieve: Access | Unset | None = UNSET,
create: Access | Unset | None = UNSET,
update: Access | Unset | None = UNSET,
delete: Access | Unset | None = UNSET,
)
Per-action access for crud(access=...).
An action without its own entry uses default; None means public.
hinoki.resources.CrudDeclaration ¶
CrudDeclaration(
config: _CrudConfig,
path: str,
module: str = __name__,
name: str = "",
)
What crud(...) returns: include it for plain CRUD, or apply it to a
class that adds hooks and handwritten actions.
hinoki.resources.Crud ¶
Bases: StrEnum
The generated actions replaces= can name (each is also its plain string).