tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

side effects of pydantic_model_creator(SomeModel)

Open FIRDOUS-BHAT opened this issue 2 years ago • 4 comments

As an example, Users_pydantic.from_queryset(Users.filter(is_active=True)) This query sometimes becomes so dangerous that It takes lot of time in fetching the data because of the relational data. It returns all the data that is related to the foreign key of this Model.

FIRDOUS-BHAT avatar May 06 '22 17:05 FIRDOUS-BHAT

Yes, what's your idea?

long2ice avatar May 07 '22 00:05 long2ice

What's the alternate for this query?

FIRDOUS-BHAT avatar May 09 '22 06:05 FIRDOUS-BHAT

I think It' solve with exlude in pydantic_model_creator. If some fields are not needed for your task

andvarfolomeev avatar May 11 '22 12:05 andvarfolomeev

What if we need to only return an object of a foreign key but it returns all its objects of other models as well which basically aren't directly linked with the base model. How we can exclude those nested objects?

FIRDOUS-BHAT avatar May 11 '22 14:05 FIRDOUS-BHAT