Skip to content
qubeejs/angular
3.8/API/DirectusResponseStrategy

DirectusResponseStrategy

ArchivedThese are the docs for ng-qubee 3.8. Read the 4.0 docs for @qubeejs/angular.

Defined in: src/lib/strategies/directus-response.strategy.ts:41

Response strategy for the Directus driver

Parses Directus collection responses (with meta=total_count,filter_count requested, which the request strategy always does):

{
"data": [{ "id": 1, "title": "Hello" }],
"meta": { "total_count": 48, "filter_count": 12 }
}

The default total path is meta.filter_count — the number of items matching the current filter, which is the relevant total for paging a filtered collection (meta.total_count ignores filters; point the total path at it via IPaginationConfig if that is what you want).

The envelope carries no current-page or page-size field, so:

  • currentPage falls back to 1 unless a currentPage path is configured and resolves (only guaranteed correct for single-page results — track the requested page in your own state for multi-page UIs).
  • perPage resolves only when a perPage path is configured.
  • lastPage is ceil(total ÷ perPage) when both are known; on a response that provably holds the whole filtered set it resolves to 1.

Every key path is overridable via IPaginationConfig (dot notation supported), so custom wrappers that do include paging fields map without subclassing.

https://docs.directus.io/reference/query.html#meta

  • AbstractDotPathResponseStrategy

new DirectusResponseStrategy(): DirectusResponseStrategy

DirectusResponseStrategy

AbstractDotPathResponseStrategy.constructor

paginate<T>(response, options): PaginatedCollection<T>

Defined in: src/lib/strategies/directus-response.strategy.ts:51

Parse a Directus collection response into a PaginatedCollection

T extends IPaginatedObject

Record<string, any>

The raw API response body

ResponseOptions

The response key name configuration (dot-notation paths supported)

PaginatedCollection<T>

A typed PaginatedCollection instance

AbstractDotPathResponseStrategy.paginate


protected resolve(response, path): unknown

Defined in: src/lib/strategies/abstract-dot-path-response.strategy.ts:73

Resolve a value from a response object using a dot-notation path

Supports both flat keys ('data') and nested paths ('meta.totalItems').

Record<string, any>

The raw response object

string

The dot-notation path to resolve

unknown

The resolved value, or undefined if any segment is missing

AbstractDotPathResponseStrategy.resolve


protected resolveFrom(response, options, currentPage, perPage?): number | undefined

Defined in: src/lib/strategies/abstract-dot-path-response.strategy.ts:90

Resolve the “from” index value

If options.from resolves to a value in the response, use it. Otherwise compute (currentPage - 1) * perPage + 1 when both are known.

Record<string, any>

The raw response object

ResponseOptions

The response key name configuration

number

The current page number

number

The number of items per page

number | undefined

The “from” index, or undefined when neither path nor inputs suffice

AbstractDotPathResponseStrategy.resolveFrom


protected resolveTo(response, options, currentPage, perPage?, total?): number | undefined

Defined in: src/lib/strategies/abstract-dot-path-response.strategy.ts:119

Resolve the “to” index value

If options.to resolves to a value in the response, use it. Otherwise compute Math.min(currentPage * perPage, total) when all three are known.

Record<string, any>

The raw response object

ResponseOptions

The response key name configuration

number

The current page number

number

The number of items per page

number

The total number of items

number | undefined

The “to” index, or undefined when neither path nor inputs suffice

AbstractDotPathResponseStrategy.resolveTo