-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
total in pagination is a string #339
Comments
Seems to be directly related to https://node-postgres.com/features/types#strings-by-default |
Yes, I had the feeling it was to do with bigints. Do you think we should maybe handle this case somehow? I think the cases where someone would have a bigint are super small, and everyone suffers from that. Maybe we could detect normal ints and then convert the number to int, and for bigints leave as a string (or wrap in a bigint lib). But at a minimum, I think this should be documented. As the docs show the total being an int. |
Agree, it must be in the documentation. Detecting and converting behind the scenes is not a good idea, since you are modifying the input and people never know, whether to expect a |
Maybe a config option, at least? It's pretty tedious to wrap every output just to change |
I'm wondering if this would be possible via a custom serializer? Does serializer apply to pagination meta data too? |
If a value is a You can read more about bigInts issue with Javascript in general. I am happy accepting PR for the docs though |
Yeah, I am aware. But I don't care about bigint for 99% of projects. They'll never reach that level of data. I am just trying to solve it for myself. Not saying it needs to be part of core. Just trying to find a good solution which does not require unwraping and re-casting every database response. I am just thinking out-loud re customer serializers. Is it something that can be applied in this case? If we have a clear path to solving it, I'll document it too. |
In that case, what you can do is use the |
I've had this issue in all of my projects. Only the "page" value is a string though. Using mysql |
Database: Postgres
Using pagination and the
total
field is returned as a string, where all the rest of the pagination values are a number.The text was updated successfully, but these errors were encountered: