-
How can I enable the "total" field in the result page for sqlalchemy cursor pagination? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Hi @holtgrewe, Currently, you need to define a custom page for this: from typing import Generic, TypeVar
from fastapi_pagination.bases import CursorRawParams
from fastapi_pagination.cursor import CursorPage, CursorParams
T = TypeVar("T")
class TotalCursorParams(CursorParams):
def to_raw_params(self) -> CursorRawParams:
params = super().to_raw_params()
params.include_total = True
return params
class TotalCursorPage(CursorPage[T], Generic[T]):
__params_type__ = TotalCursorParams |
Beta Was this translation helpful? Give feedback.
-
This issue should be a part of the documentation for Cursor if it's not already. Also, the provided solution didn't work for me. |
Beta Was this translation helpful? Give feedback.
-
Yeah I didn't include My CursorPage isn't customized right now, it's just imported I'm not sure if CustomizedPage would be a good replacement, since don't I need to set params each time via the cursor and size params (as chosen by the user during the call)? |
Beta Was this translation helpful? Give feedback.
-
I'm unable to get this to work with cassandra, could someone please guide me or show an example of how to implement it? Thanks! |
Beta Was this translation helpful? Give feedback.
Hi @holtgrewe,
Currently, you need to define a custom page for this: