Skip to main content
Version: next

Payload Driver

Targets Payload — the TypeScript-native headless CMS / application framework, with its bracket-based where query syntax and the mongoose-paginate-v2 response envelope.

Configure

import { DriverEnum, provideNgQubee } from 'ng-qubee';

bootstrapApplication(AppComponent, {
providers: [provideNgQubee({ driver: DriverEnum.PAYLOAD })]
});

Wire format

ConcernOutput
Filters (single value)where[field][equals]=value
Filters (multi-value)where[field][in]=v1,v2 (CSV)
Operator filterswhere[field][op]=value — see below
Sortsort=-createdAt,title (CSV, - prefix = DESC)
Selectselect[col1]=true&select[col2]=true
Paginationpage=N&limit=M

The where / sort / select / page / limit keys are fixed by Payload's REST endpoints and ignore request key overrides. Simple filters and operator filters merge into a single where[...] block; both kinds can co-exist on the same field.

Relationship population is controlled by Payload's numeric depth param rather than a named-relation list, so addIncludes throws UnsupportedIncludesError — append depth=N through your HTTP layer when needed.

Operator filters

FilterOperatorEnum translates to Payload's where operators:

import { FilterOperatorEnum } from 'ng-qubee';

qb.addFilterOperator('views', FilterOperatorEnum.GT, 100); // where[views][greater_than]=100
qb.addFilterOperator('title', FilterOperatorEnum.CONTAINS, 'hello'); // where[title][contains]=hello
qb.addFilterOperator('title', FilterOperatorEnum.ILIKE, 'hello'); // where[title][like]=hello
qb.addFilterOperator('id', FilterOperatorEnum.IN, 1, 2, 3); // where[id][in]=1,2,3
qb.addFilterOperator('status', FilterOperatorEnum.NOT, 'draft'); // where[status][not_equals]=draft
qb.addFilterOperator('price', FilterOperatorEnum.BTW, 10, 50); // where[price][greater_than_equal]=10&where[price][less_than_equal]=50
qb.addFilterOperator('deletedAt', FilterOperatorEnum.NULL, true); // where[deletedAt][exists]=false

Translation table

FilterOperatorEnumPayload operator
EQequals
GT / GTE / LT / LTEgreater_than / greater_than_equal / less_than / less_than_equal
CONTAINScontains (case-insensitive substring)
ILIKElike (case-insensitive, word-based)
INin (CSV)
BTWgreater_than_equal + less_than_equal pair (arity-checked)
NOT (single)not_equals
NOT (multi)not_in (CSV)
NULLexists with inverted boolean (trueexists=false ⇔ IS NULL); arity/type-checked
SWunsupported — no starts-with operator; throws UnsupportedFilterOperatorError
FTS / PHFTS / PLFTS / WFTSunsupported — throws UnsupportedFilterOperatorError

Payload's near / within / intersects geo operators and all have no FilterOperatorEnum counterpart and are not exposed.

Value shape rules

BTW requires exactly 2 values (min, max); NULL requires exactly 1 boolean — both enforced at call time with InvalidFilterOperatorValueError. Other operators leave shape validation to the server.

Feature matrix

MethodSupported?Notes
addFilter / deleteFiltersequals (single) or in CSV (multi) inside the where block
addFilterOperator / deleteOperatorFiltersSee translation table above
addSort / deleteSortsCSV sort= with - prefix for DESC
setLimit / setPagepage + limit
addSelect / deleteSelectselect[col]=true flags (dotted names pass through for nested selection)
addFields / deleteFields / deleteFieldsByModelNo per-model field selection
addIncludes / deleteIncludesPopulation is depth-based (depth=N), not a named-relation list
addEmbedded / deleteEmbeddedThrows UnsupportedEmbeddedError
setSearch / deleteSearchNo global search param — use a CONTAINS/ILIKE operator filter instead

Response shape

Payload emits the mongoose-paginate-v2 envelope — flat, with page numbers (not URLs) for navigation:

{
"docs": [{ "id": "abc123", "title": "Hello" }],
"totalDocs": 48,
"limit": 10,
"totalPages": 5,
"page": 2,
"pagingCounter": 11,
"hasPrevPage": true,
"hasNextPage": true,
"prevPage": 1,
"nextPage": 3
}

PayloadResponseStrategy maps docs → data, totalDocs → total, limit → perPage, totalPages → lastPage, page → page — and pagingCounter, the 1-indexed offset of the first doc on the page, straight onto from; to is computed from page × limit (clamped to the total). Because prevPage/nextPage are numbers, the URL slots on PaginatedCollection stay undefined.

Since the envelope comes from mongoose-paginate-v2, this driver also fits any Express/Mongoose backend using that plugin — not just Payload.

All key paths are configurable (dot notation supported):

provideNgQubee({
driver: DriverEnum.PAYLOAD,
response: {
data: 'results',
total: 'count'
}
});

Defaults are encoded in PayloadResponseOptions.