Spring Data REST Driver
ArchivedThese are the docs for ng-qubee 3.8. Read the 4.0 docs for @qubeejs/angular.
Targets Spring Data REST — the standard pagination and sorting convention in the Java / Spring Boot ecosystem, with HAL (Hypertext Application Language) responses.
Configure
Section titled “Configure”import { DriverEnum, provideNgQubee } from 'ng-qubee';
bootstrapApplication(AppComponent, { providers: [provideNgQubee({ driver: DriverEnum.SPRING })]});Wire format
Section titled “Wire format”| Concern | Output |
|---|---|
| Sort | sort=field,asc&sort=other,desc (repeatable param, one per rule) |
| Pagination | page=N&size=N — page is 0-indexed on the wire |
qb.setResource('users') .addSort('lastName', SortEnum.ASC) .addSort('createdAt', SortEnum.DESC) .setLimit(20) .setPage(2);
// → /users?sort=lastName,asc&sort=createdAt,desc&page=1&size=20Feature matrix
Section titled “Feature matrix”| Method | Supported? | Notes |
|---|---|---|
addSort / deleteSorts |
✓ | Repeatable sort=field,dir params, lowercase direction |
setLimit / setPage |
✓ | Emitted as size + 0-indexed page |
addFilter / deleteFilters |
✗ | No standard filter convention — Spring expects custom query methods / Specifications server-side |
addFilterOperator / deleteOperatorFilters |
✗ | Same as above |
addSelect / deleteSelect |
✗ | No standard projection parameter (Spring’s projection is excerpt-based, not a column list) |
addFields / deleteFields / deleteFieldsByModel |
✗ | No per-model field selection |
addIncludes / deleteIncludes |
✗ | Associations are navigated via HAL links, not query params |
addEmbedded / deleteEmbedded |
✗ | PostgREST-only — throws UnsupportedEmbeddedError |
setSearch / deleteSearch |
✗ | No standard search parameter |
Response shape (HAL)
Section titled “Response shape (HAL)”{ "_embedded": { "users": [ { "id": 1, "name": "John" } ] }, "_links": { "first": { "href": "http://api.example.com/users?page=0&size=20" }, "prev": { "href": "http://api.example.com/users?page=0&size=20" }, "next": { "href": "http://api.example.com/users?page=2&size=20" }, "last": { "href": "http://api.example.com/users?page=4&size=20" } }, "page": { "size": 20, "totalElements": 100, "totalPages": 5, "number": 1 }}SpringResponseStrategy reads page.{size,totalElements,totalPages,number} (converting the 0-indexed number to a 1-indexed page), pulls navigation URLs from _links.*.href, and computes from/to from page × size.
The _embedded rel name
Section titled “The _embedded rel name”HAL nests the collection under the resource’s rel name — _embedded.users, _embedded.articles — which the library cannot know statically. By default the strategy looks at _embedded and picks the first array inside it, which is correct for every standard listing endpoint (Spring emits exactly one collection rel). If your payload carries multiple embedded rels, pin the exact path:
provideNgQubee({ driver: DriverEnum.SPRING, response: { data: '_embedded.users' }});When _embedded is absent (Spring omits it on empty result sets), data resolves to an empty array.
Customising response paths
Section titled “Customising response paths”provideNgQubee({ driver: DriverEnum.SPRING, response: { total: 'page.totalElements', nextPageUrl: '_links.next.href' }});Defaults are encoded in SpringResponseOptions.