OData v4
driverodata7/8 capabilities
Import the driver directly so the other seventeen tree-shake away.
import { ODATA_DRIVER, QubeeStore, QueryBuilder, Paginator } from '@qubeejs/core';
const store = new QubeeStore();const qb = new QueryBuilder(store, ODATA_DRIVER.createRequestStrategy('query'));const paginator = new Paginator( store, ODATA_DRIVER.createResponseStrategy(), ODATA_DRIVER.createResponseOptions({}),);Example query
Section titled “Example query”qb.setResource('articles') .addFilter('status', 'published') .addSort('createdAt', SortEnum.DESC) .setLimit(25) .generateUri();Produces:
/articles?$filter=status eq 'published'&$orderby=createdAt desc&$count=true&$top=25Capabilities
Section titled “Capabilities”| Capability | Supported |
|---|---|
| Filters | ✅ |
| Operators | ✅ |
| Sort | ✅ |
| Select | ✅ |
| Fields | — |
| Includes | ✅ |
| Search | ✅ |
| Embedded | ✅ |
Reading a response
Section titled “Reading a response”const body = await fetch(`https://example.com/api${uri}`).then((r) => r.json());const page = paginator.paginate(body);
page.data; // rowspage.total; // total rows the backend reportedpage.lastPage; // final page number