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

Argument to skip cannot be negative? #21

Closed MichaelLiss closed 2 years ago

MichaelLiss commented 4 years ago

Hi,

I am defining a pretty simple aggregation as follows:

[
  {
    "$match": {}
  },
  {
    "$sort": {
      "userType": 1,
      "role": 1,
      "lName": 1,
      "name": 1
    }
  },
  {
    "$project": {
      "lName": 1,
      "_id": 0,
      "role": 1,
      "userType": 1
    }
  }
]

I define the page and limit as:

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

I am getting back an error;

\"Argument to $skip cannot be negative\"
aravindnc commented 4 years ago

You are sending page = 0; page should be 1 or higher.