Skip to content

Sorted result in mongoose-aggregate-paginate-v2 is changing #18

@asmafakhfakh

Description

@asmafakhfakh

I'm sending a query with postman to an apollo server to get a list of users.
This is my options object:

const options = {
            page: parseInt(page),
            limit: 15,
            lean: true,
            pagination: true,
            sort:{ lastUpdate: "descending", creationDateTime:"descending"}
        }

Sometimes when I resend the request with exactly the same parameters, the result changes even though my data is the same.
These are some samples of different results I got:
sample 1:

{
    "listOfUsers": {
        "list": [
            {
                "lastUpdate": "2020-03-27T06:00:47.689Z",
                "creationDateTime": "2019-10-09T11:20:13.004Z"
            },
            {
                "lastUpdate": "2020-03-27T05:54:00.105Z",
                "creationDateTime": "2020-01-06T12:54:16.699Z"
            },
            {
                "lastUpdate": "2020-03-19T18:36:29.163Z",
                "creationDateTime": "2019-10-21T11:16:30.428Z"
            },
            {
                "lastUpdate": "2020-03-19T17:46:36.799Z",
                "creationDateTime": "2020-01-06T09:43:41.844Z"
            },
            {
                "lastUpdate": null,
                "creationDateTime": "2020-01-06T10:55:47.714Z"
            }
        ],
        "totalDocs": 5,
        "limit": 15,
        "totalPages": 1,
        "page": 1,
        "pagingCounter": 1,
        "hasPrevPage": false,
        "hasNextPage": false,
        "prevPage": null,
        "nextPage": null
    }
}

sample 2:

{
    "listOfUsers": {
        "list": [
            {
                "lastUpdate": "2020-03-27T06:00:47.689Z",
                "creationDateTime": "2019-10-09T11:20:13.004Z"
            },
            {
                "lastUpdate": "2020-03-27T05:54:00.105Z",
                "creationDateTime": "2020-01-06T12:54:16.699Z"
            },
            {
                "lastUpdate": "2020-03-19T17:46:36.799Z",
                "creationDateTime": "2020-01-06T09:43:41.844Z"
            },
            {
                "lastUpdate": null,
                "creationDateTime": "2020-01-06T10:55:47.714Z"
            },
            {
                "lastUpdate": "2020-03-19T18:36:29.163Z",
                "creationDateTime": "2019-10-21T11:16:30.428Z"
            }
        ],
        "totalDocs": 5,
        "limit": 15,
        "totalPages": 1,
        "page": 1,
        "pagingCounter": 1,
        "hasPrevPage": false,
        "hasNextPage": false,
        "prevPage": null,
        "nextPage": null
    }
}

sample 3:

{
    "listOfUsers": {
        "list": [
            {
                "lastUpdate": "2020-03-19T18:36:29.163Z",
                "creationDateTime": "2019-10-21T11:16:30.428Z"
            },
            {
                "lastUpdate": "2020-03-27T06:00:47.689Z",
                "creationDateTime": "2019-10-09T11:20:13.004Z"
            },
            {
                "lastUpdate": "2020-03-19T17:46:36.799Z",
                "creationDateTime": "2020-01-06T09:43:41.844Z"
            },
            {
                "lastUpdate": "2020-03-27T05:54:00.105Z",
                "creationDateTime": "2020-01-06T12:54:16.699Z"
            },
            {
                "lastUpdate": null,
                "creationDateTime": "2020-01-06T10:55:47.714Z"
            }
        ],
        "totalDocs": 5,
        "limit": 15,
        "totalPages": 1,
        "page": 1,
        "pagingCounter": 1,
        "hasPrevPage": false,
        "hasNextPage": false,
        "prevPage": null,
        "nextPage": null
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions