-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Labels
FastCRUD MethodsRelated to FastCRUD methodsRelated to FastCRUD methodsenhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
I can't find a way to annotate number of related objects using the fastcrud.get_multi(). This is a raw sqlalchemy query I have instead: [note m2m relationship in this specific case]
searches = await db.execute(
select(Search, func.count(Video.id))
.outerjoin(VideoSearchAssociation)
.outerjoin(Video, VideoSearchAssociation.video_id == Video.id)
.group_by(Search.id)
)
Describe the solution you'd like
I'd like to be able to retrieve videos_count
from search_crud.get_multi() method and potentialy others. Extending to_select
with func.count(Video.id) seems relatively easy, but whole query must be wrapped in a GROUP_BY clause, which seems to be a bit harder to implement in an elegant way. Maybe some CountConfig resembling JoinConfig would be a way to go?
Metadata
Metadata
Assignees
Labels
FastCRUD MethodsRelated to FastCRUD methodsRelated to FastCRUD methodsenhancementNew feature or requestNew feature or request