Skip to content

Strapi

driverstrapi5/8 capabilities

Import the driver directly so the other seventeen tree-shake away.

strapi.ts
import { STRAPI_DRIVER, QubeeStore, QueryBuilder, Paginator } from '@qubeejs/core';
const store = new QubeeStore();
const qb = new QueryBuilder(store, STRAPI_DRIVER.createRequestStrategy('query'));
const paginator = new Paginator(
store,
STRAPI_DRIVER.createResponseStrategy(),
STRAPI_DRIVER.createResponseOptions({}),
);
qb.setResource('articles')
.addFilter('status', 'published')
.addSort('createdAt', SortEnum.DESC)
.setLimit(25)
.generateUri();

Produces:

/articles?filters[status][$eq]=published&sort[0]=createdAt:desc&pagination[page]=1&pagination[pageSize]=25
Capability Supported
Filters
Operators
Sort
Select
Fields
Includes
Search
Embedded
const body = await fetch(`https://example.com/api${uri}`).then((r) => r.json());
const page = paginator.paginate(body);
page.data; // rows
page.total; // total rows the backend reported
page.lastPage; // final page number