igorbenav/fastcrud

nested model

Closed this issue · 2 comments

I try to create api on sqlmodel with relationships (In my case, I have table Card and Article with link to Card (key: card_id))
one-to-many

And now I try to understand how it works (joined isn't my solving, I need record which contain Card model with list of Article models inside)
image

code of getting record

return await card_crud.get(
                db=db,
                id=card_id,
                schema_to_select=Card_schema,
            )

result of this response
image

Why "true" ....?
How did it appeared ....?

how can I implement this?

in Usual SQL I would use this
selectinload

but how can I make this in FastCRUD

I think what you are looking for is the get_joined method.

Here's a comprehensive guide to joins in FastCRUD, including nested joins