thomas4019 / expressa

API creation middleware with an admin interface
MIT License
439 stars 27 forks source link

Postgres Count with OFFSET and LIMIT bug #216

Open kane-mason opened 5 months ago

kane-mason commented 5 months ago

Count is not accurate when using offset and limit.

See here for potential fix https://dba.stackexchange.com/questions/117284/count-gives-more-than-1-with-limit-1

thomas4019 commented 5 months ago

By count, do you mean the itemsTotal field that gets returned? I feel like that should return the complete amount and if someone needs to count of just those in a specific page's response, then you can just use something like data.length. Thoughts?

kane-mason commented 2 weeks ago

Sorry for the late response. I mean count as in api.db[collection].count, if you set a limit of 1 you expect at most a count of 1 to be returned, but this is not the case.