aravindnc / mongoose-aggregate-paginate-v2

A cursor based custom aggregate pagination library for Mongoose with customizable labels.
MIT License
131 stars 23 forks source link

Why 'page' is 1 based? #20

Closed MichaelLiss closed 2 years ago

MichaelLiss commented 4 years ago

Why is page 1 based instead of 0 based?

When I send in:

{"page":0,"limit":3}

I get back:

{
    "data": [
        {
            "role": 21,
            "userType": 10,
            "lName": "BBBB"
        },
        {
            "role": 21,
            "userType": 10,
            "lName": "KKKK"
        },
        {
            "role": 21,
            "userType": 10,
            "lName": "LLLL"
        }
    ],
    "pageCount": 3,
    "totalCount": 7
}

When I send in:

{"page":1,"limit":3}

I get back:

{
    "data": [
        {
            "role": 21,
            "userType": 10,
            "lName": "BBBB"
        },
        {
            "role": 21,
            "userType": 10,
            "lName": "KKKK"
        },
        {
            "role": 21,
            "userType": 10,
            "lName": "LLLL"
        }
    ],
    "pageCount": 3,
    "totalCount": 7
}

I am using Java (and most other languages for web programming) and data structures are 0 (zero) based, not 1 based.

get the first entry of array array[0].someField

get the second array[1].someField

See Array system cross-reference list here: https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(array)

https://en.wikipedia.org/wiki/Zero-based_numbering https://medium.com/analytics-vidhya/array-indexing-0-based-or-1-based-dd89d631d11c

aravindnc commented 4 years ago

@MichaelLiss Paging usually starts with 1. This has nothing to do with array index based numbering.