fastapi-listing
fastapi-listing copied to clipboard
Async Session
Hello!
Can this work with AsyncSession? I am trying to work with the examples but I cannot seem to be able to overwrite the sorter.
I get this error
fastapi_listing/sorter/page_sorter.py
File "/opt/pysetup/.venv/lib/python3.11/site-packages/fastapi_listing/sorter/page_sorter.py", line 20, in sort_dsc_util
query = query.order_by(inst_field.desc())
AttributeError: 'coroutine' object has no attribute 'order_by'
I have overwrite the get_default_read
to work with async, but I cannot see how to do that in the page_sorter.
class VideoDao(GenericDao):
def __init__(self, db: AsyncSession) -> None:
super().__init__(db)
name = "videoresponse"
model = Videos
async def get_default_read(self, fields_to_read: Optional[list]):
query = await self.db.query(Videos)
return query