Skip to content

Expose simpler interface to override EndpointCreator methods #118

@JakNowy

Description

@JakNowy

Let's say you want to use crud.get_joined on your router read_item method. What you end up doing is something like:

class MyItemRouter(EndpointCreator):
    def _read_items(self):
        """Creates an endpoint for reading multiple items from the database."""

        async def endpoint(
            db: SessionDep,
        ) -> list[MissionObjectives]:
            return await self.crud.get_joined(db, <joined_params...>)

        return endpoint

Implementing your own crud methods and calling them in overriden EndpointCreator methods should be common and simple approach, while currently it's quite verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions