igorbenav / fastcrud

FastCRUD is a Python package for FastAPI, offering robust async CRUD operations and flexible endpoint creation utilities.
MIT License
530 stars 32 forks source link

Nested Join Should Return List When Necessary #91

Closed igorbenav closed 1 month ago

igorbenav commented 1 month ago

This was mentioned in #90

async def get_card(self, card_id: uuid.UUID):
        async with async_session_maker() as db:
            return await card_crud.get_joined(
                db=db,
                id=card_id,
                nest_joins=True,
                joins_config=[
                    JoinConfig(
                        model=Article,
                        join_on=Article.card_id == Card.id,
                        join_type="left",
                        join_prefix="articles_",
                        schema_to_select=Article_schema,
                    )
                ]
            )

Assuming a card has multiple articles, articles in joined response should be a list of articles.