简体   繁体   English

如何禁用羽毛服务中的分页?

[英]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. 我有100多个测试记录,但在回调中,我仅收到10条记录。 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. 但我想禁用分页功能,以免收到来自mongo的所有记录。 How can I do that? 我怎样才能做到这一点?

To disable pagination, remove the paginate option. 要禁用分页,请删除paginate选项。 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 分页响应:具有data数组属性的对象

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

Response without pagination: the data array 没有分页的响应:数据数组

[/* the data is here */]

As @daff already pointed out in the answer above, you can disable Pagination in your configuration, although this is really not recommended. 正如@daff在上面的答案中已经指出的那样,您可以在配置中禁用分页,尽管实际上不建议这样做。

Also you can disable pagination for a service call once in the service call. 您也可以在服务呼叫中一次禁用服务呼叫的分页。

service.find({ paginate:false})

This was discussed on Github here 这是Github上讨论在这里

The documentation for this feature can be found here 可以在这里找到此功能的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM