fastcrud icon indicating copy to clipboard operation
fastcrud copied to clipboard

Join list of objects

Open JakNowy opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. For OneToMany relationships, using get_joined or get_multi_joined returns one nested object, while in some cases I'd like to return all related objects.

Describe the solution you'd like fastcrud.get_joined_list(...) ->

{
    "id": 1,
    "joined_objects": [
        {
            "id":1
            "name": Donald,
        },
        {
            "id":2
            "name": Joe,
        },
    ]
}

JakNowy avatar Jul 04 '24 13:07 JakNowy

Can you please send code to reproduce and output?

igorbenav avatar Jul 09 '24 03:07 igorbenav

What I exactly mean here is to introduce fastcrud.get_joined_many() method which would return an object with a list of relationships.

So on top of existing fastcrud.get_joined() ->

{
    "id": 1,
    "joined_object": {   # just 1 relationship object
            "id":1
            "name": Donald,
        }
}

we add fastcrud.get_joined_many() ->

{
    "id": 1,
    "joined_objects": [    # multiple relationship objects
        {
            "id":1
            "name": Donald,
        },
        {
            "id":2
            "name": Joe,
        },
    ]
}

Does it make sense to you to add such feature or it's too compllicated?

JakNowy avatar Jul 24 '24 12:07 JakNowy

Maybe its about relationship_type?

relationship_type: Specifies the relationship type, such as "one-to-one" or "one-to-many". Default is "one-to-one". https://igorbenav.github.io/fastcrud/advanced/joins/#handling-one-to-one-and-one-to-many-joins-in-fastcrud https://igorbenav.github.io/fastcrud/advanced/joins/#one-to-many-relationships https://igorbenav.github.io/fastcrud/advanced/joins/#many-to-many-relationships-with-get_multi_joined

neatek avatar Sep 17 '24 06:09 neatek