Search code examples
node.jsmongodbmongoosefeathersjs

How to disable pagination in feathers service?


Hi I try populate my datatable using feathers service in this way:

app.service('pupils').find({}, (error, result) => {

    $('#pupils > table').DataTable({
        "pageLength": view.short,
        "lengthChange": false,
        "info" : false,
        "responsive": true,
        "data": result.data,
        "deferRender": true,
        "columns": [ ... ]
    });

}); 

I have more than 100 testing records but in callback I receive only 10 records. I receive more records after added below code in feathers service:

paginate: {
   default: 100,
   max: 200
 }

but I would like to disable pagination for received all records from mongo. How can I do that?


Solution

  • To disable pagination, remove the paginate option. Not recommended for production however since it might bring down both, the client and the server if you try to send many thousands of records.

    Note: the response object changes depending on whether you are using pagination:

    Response with pagination: object with data array property

    {
       total: 572,
       limit: 50,
       skip: 4,
       data: [/* the data is here */]
    }
    

    Response without pagination: the data array

    [/* the data is here */]