@nestjsx/crud
drivernestjsx-crud5/8 capabilities
Import the driver directly so the other seventeen tree-shake away.
import { NESTJSX_CRUD_DRIVER, QubeeStore, QueryBuilder, Paginator } from '@qubeejs/core';
const store = new QubeeStore();const qb = new QueryBuilder(store, NESTJSX_CRUD_DRIVER.createRequestStrategy('query'));const paginator = new Paginator( store, NESTJSX_CRUD_DRIVER.createResponseStrategy(), NESTJSX_CRUD_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&sort=createdAt,DESC&limit=25&page=1Capabilities
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