1 line
5.3 KiB
JavaScript
1 line
5.3 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[18],{199:function(t,a,e){"use strict";e.r(a);var s=e(6),n=Object(s.a)({},(function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h1",{attrs:{id:"pagination"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#pagination"}},[t._v("#")]),t._v(" Pagination")]),t._v(" "),e("p",[t._v("By default, resource listings are automatically "),e("a",{attrs:{href:"https://jsonapi.org/format/#fetching-pagination",target:"_blank",rel:"noopener noreferrer"}},[t._v("paginated"),e("OutboundLink")],1),t._v(" with 20 records per page.")]),t._v(" "),e("p",[t._v("You can change this amount using the "),e("code",[t._v("paginate")]),t._v(" method on the schema builder, or you can remove it by calling the "),e("code",[t._v("dontPaginate")]),t._v(" method.")]),t._v(" "),e("div",{staticClass:"language-php extra-class"},[e("pre",{pre:!0,attrs:{class:"language-php"}},[e("code",[e("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$type")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("->")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("paginate")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("50")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// default to listing 50 resources per page")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$type")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("->")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("dontPaginate")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// default to listing all resources")]),t._v("\n")])])]),e("p",[t._v("Consumers may request a different limit using the "),e("code",[t._v("page[limit]")]),t._v(" query parameter. By default the maximum possible limit is capped at 50; you can change this cap using the "),e("code",[t._v("limit")]),t._v(" method, or you can remove it by calling the "),e("code",[t._v("noLimit")]),t._v(" method:")]),t._v(" "),e("div",{staticClass:"language-php extra-class"},[e("pre",{pre:!0,attrs:{class:"language-php"}},[e("code",[e("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$type")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("->")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("limit")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token number"}},[t._v("100")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// set the maximum limit for resources per page to 100")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$type")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("->")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("noLimit")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// remove the maximum limit for resources per page")]),t._v("\n")])])]),e("h2",{attrs:{id:"countability"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#countability"}},[t._v("#")]),t._v(" Countability")]),t._v(" "),e("p",[t._v("By default, a query will be performed to count the total number of resources in a collection. This will be used to populate a "),e("code",[t._v("total")]),t._v(" attribute in the document's "),e("code",[t._v("meta")]),t._v(" object, as well as the "),e("code",[t._v("last")]),t._v(" pagination link.")]),t._v(" "),e("p",[t._v("For some types of resources, or when a query is resource-intensive (especially when certain filters or sorting is applied), it may be undesirable to have this happen. So it can be toggled using the "),e("code",[t._v("countable")]),t._v(" and "),e("code",[t._v("uncountable")]),t._v(" methods:")]),t._v(" "),e("div",{staticClass:"language-php extra-class"},[e("pre",{pre:!0,attrs:{class:"language-php"}},[e("code",[e("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$type")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("->")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("countable")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n"),e("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$type")]),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("->")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("uncountable")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n")])])])])}),[],!1,null,null,null);a.default=n.exports}}]); |