SeaDog
SeaDog

Reputation: 655

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?

Upvotes: 5

Views: 5667

Answers (3)

Santanu Prasad Sahoo
Santanu Prasad Sahoo

Reputation: 121

to disable Pagination on the service, you need to pass pagination as false on the service file.

const options = {
    Model: createModel(app),
    paginate: false,
};

Upvotes: 0

Yuna
Yuna

Reputation: 122

As @daff already pointed out in the answer above, you can disable Pagination in your configuration, although this is really not recommended.

Also you can disable pagination for a service call once in the service call.

service.find({ paginate:false})

This was discussed on Github here

The documentation for this feature can be found here

Upvotes: 3

Daff
Daff

Reputation: 44215

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 */]

Upvotes: 9

Related Questions