Skip to content
qubeejs/angular
3.8/API/NgQubeeService

NgQubeeService

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

Defined in: src/lib/services/ng-qubee.service.ts:36

new NgQubeeService(_nestService, requestStrategy, driver, options?): NgQubeeService

Defined in: src/lib/services/ng-qubee.service.ts:65

NestService

IRequestStrategy

DriverEnum

QueryBuilderOptions = ...

NgQubeeService

uri$: Observable<string>

Defined in: src/lib/services/ng-qubee.service.ts:61

Observable that emits non-empty generated URIs

addEmbedded(relation, …columns): this

Defined in: src/lib/services/ng-qubee.service.ts:115

Add an embedded resource to the select statement (PostgREST only)

Splices relation(col1,col2) into the single select= query parameter alongside flat columns from addSelect. Omit the columns to project all of them (relation(*)):

qb.addEmbedded('author', 'id', 'name')
.addEmbedded('comments')
.addSelect('title');
// → select=title,author(id,name),comments(*)

Calling repeatedly with the same relation merge-dedups the columns. Does not reset the page (column shape change, not record-set change).

string

The related table / foreign-key name as PostgREST sees it

…string[]

Optional column projection; omit for relation(*)

this

If the active driver does not support embedded resources


addFields(model, fields): this

Defined in: src/lib/services/ng-qubee.service.ts:131

Add fields to the select statement for the given model (JSON:API and Spatie only)

string

Model that holds the fields

string[]

Fields to select

this

If the active driver does not support per-model field selection


addFilter(field, …values): this

Defined in: src/lib/services/ng-qubee.service.ts:153

Add a filter with the given value(s) (JSON:API, NestJS, PostgREST, and Spatie)

Produces: filter[field]=value (JSON:API / Spatie) or filter.field=value (NestJS)

string

Name of the field to filter

…(string | number | boolean)[]

The needle(s)

this

If the active driver does not support filters


addFilterOperator(field, operator, …values): this

Defined in: src/lib/services/ng-qubee.service.ts:179

Add a filter with an explicit operator (NestJS and PostgREST)

Produces: filter.field=$operator:value

string

Name of the field to filter

FilterOperatorEnum

The filter operator to apply

…(string | number | boolean)[]

The value(s) for the filter

this

If the active driver does not support filter operators


addIncludes(…models): this

Defined in: src/lib/services/ng-qubee.service.ts:199

Add related entities to include in the request (JSON:API and Spatie only)

…string[]

Models to include

this

If the active driver does not support includes


addSelect(…fields): this

Defined in: src/lib/services/ng-qubee.service.ts:220

Add flat field selection (NestJS and PostgREST)

Produces: select=col1,col2

…string[]

Fields to select

this

If the active driver does not support flat field selection


addSort(field, order): this

Defined in: src/lib/services/ng-qubee.service.ts:240

Add a field with a sort criteria (JSON:API, NestJS, PostgREST, and Spatie)

string

Field to use for sorting

SortEnum

A value from the SortEnum enumeration

this

If the active driver does not support sorts


currentPage(): number

Defined in: src/lib/services/ng-qubee.service.ts:258

Get the current page number

number

The current page number

Always safe to call. Thin accessor over the internal state’s page field.


deleteEmbedded(…relations): this

Defined in: src/lib/services/ng-qubee.service.ts:271

Remove embedded resources from the current query builder state (PostgREST only)

Removes the whole relation entry, columns included.

…string[]

Relation names to remove

this

If the active driver does not support embedded resources


deleteFields(fields): this

Defined in: src/lib/services/ng-qubee.service.ts:297

Delete selected fields for the given models in the current query builder state (JSON:API and Spatie only)

ngQubeeService.deleteFields({
users: ['email', 'password'],
address: ['zipcode']
});

IFields

Object mapping model names to field arrays to remove

this

If the active driver does not support per-model field selection


deleteFieldsByModel(model, …fields): this

Defined in: src/lib/services/ng-qubee.service.ts:316

Delete selected fields for the given model in the current query builder state (JSON:API and Spatie only)

ngQubeeService.deleteFieldsByModel('users', 'email', 'password');

string

Model that holds the fields

…string[]

Fields to delete from the state

this

If the active driver does not support per-model field selection


deleteFilters(…filters): this

Defined in: src/lib/services/ng-qubee.service.ts:337

Remove given filters from the query builder state (JSON:API, NestJS, PostgREST, and Spatie)

…string[]

Filters to remove

this

If the active driver does not support filters


deleteIncludes(…includes): this

Defined in: src/lib/services/ng-qubee.service.ts:357

Remove selected related models from the query builder state (JSON:API and Spatie only)

…string[]

Models to remove

this

If the active driver does not support includes


deleteOperatorFilters(…fields): this

Defined in: src/lib/services/ng-qubee.service.ts:376

Remove operator filters by field name (NestJS and PostgREST)

…string[]

Field names of operator filters to remove

this

If the active driver does not support filter operators


deleteSearch(): this

Defined in: src/lib/services/ng-qubee.service.ts:395

Remove search term from the query builder state (NestJS only)

this

If the active driver does not support search


deleteSelect(…fields): this

Defined in: src/lib/services/ng-qubee.service.ts:410

Remove flat field selections from the query builder state (NestJS and PostgREST)

…string[]

Fields to remove from selection

this

If the active driver does not support flat field selection


deleteSorts(…sorts): this

Defined in: src/lib/services/ng-qubee.service.ts:429

Remove sort rules from the query builder state (JSON:API, NestJS, PostgREST, and Spatie)

…string[]

Fields used for sorting to remove

this

If the active driver does not support sorts


firstPage(): this

Defined in: src/lib/services/ng-qubee.service.ts:443

Navigate to the first page (page 1)

this

Never throws. Idempotent when already on page 1.


generateUri(): Observable<string>

Defined in: src/lib/services/ng-qubee.service.ts:454

Generate a URI accordingly to the given data and active driver

Observable<string>

An observable that emits the generated URI


goToPage(n): this

Defined in: src/lib/services/ng-qubee.service.ts:474

Navigate directly to the specified page

Validates integer/positive via the existing setPage path, and additionally rejects values that exceed state.lastPage when pagination bounds are known.

number

Target page number

this

If n is not a positive integer, or if n > state.lastPage when state.isLastPageKnown is true


hasNextPage(): boolean

Defined in: src/lib/services/ng-qubee.service.ts:492

Check whether a next page exists

boolean

true if state.page < state.lastPage when bounds are known, or true when bounds are unknown

Template-safe. Returns true when pagination bounds are unknown (conservative default — keeps a “Next” button enabled before the first paginate() call).


hasPreviousPage(): boolean

Defined in: src/lib/services/ng-qubee.service.ts:504

Check whether a previous page exists

boolean

true if state.page > 1

Always safe. Does not require a synced paginated response.


isFirstPage(): boolean

Defined in: src/lib/services/ng-qubee.service.ts:514

Check whether the current page is the first page

boolean

true if state.page === 1

Always safe. Does not require a synced paginated response.


isLastPage(): boolean

Defined in: src/lib/services/ng-qubee.service.ts:524

Check whether the current page is the last page

boolean

true only when state.isLastPageKnown and state.page === state.lastPage

Template-safe. Returns false when pagination bounds are unknown (no paginated response has been synced yet) — keeps “Next” navigation unblocked until the first paginate() call syncs.


lastPage(): this

Defined in: src/lib/services/ng-qubee.service.ts:537

Navigate to the last page known from the most recent paginated response

this

Requires at least one PaginationService.paginate() call to have synced state.lastPage. Before that, the bound is unknown and this method throws.

If state.isLastPageKnown is false (no paginated response has been synced yet)


nextPage(): this

Defined in: src/lib/services/ng-qubee.service.ts:555

Navigate to the next page

this

Never throws. Idempotent at the known last page (no-op). Pair with hasNextPage() for a disable-state binding.


paginationHeaders(): Record<string, string> | null

Defined in: src/lib/services/ng-qubee.service.ts:579

HTTP request headers the active driver wants the consumer to apply

Returns null for drivers that pass all pagination metadata on the URL (Laravel, Spatie, JSON:API, NestJS, and PostgREST in its default QUERY mode). Returns a map of header name → value when the active driver uses HTTP headers instead — today, only the PostgREST driver configured with PaginationModeEnum.RANGE, which yields { 'Range-Unit': 'items', 'Range': 'from-to' }.

Record<string, string> | null

Map of headers to apply to the HTTP request, or null when not needed


previousPage(): this

Defined in: src/lib/services/ng-qubee.service.ts:593

Navigate to the previous page

this

Never throws. Idempotent at page 1 (floored). Pair with hasPreviousPage() for a disable-state binding.


reset(): this

Defined in: src/lib/services/ng-qubee.service.ts:610

Clear the current state and reset the Query Builder to a fresh, clean condition

this


setBaseUrl(baseUrl): this

Defined in: src/lib/services/ng-qubee.service.ts:622

Set the base URL to use for composing the address

string

The base URL

this


setLimit(limit): this

Defined in: src/lib/services/ng-qubee.service.ts:640

Set the items per page number

Validation is delegated to the active request strategy because the accepted range is driver-specific: nestjs-paginate additionally accepts -1 as a “fetch all” sentinel, while Laravel, Spatie, and JSON:API require a positive integer.

number

Number of items per page (or -1 to fetch all, NestJS only)

this

If the value is not accepted by the active driver


setPage(page): this

Defined in: src/lib/services/ng-qubee.service.ts:654

Set the page that the backend will use to paginate the result set

number

Page number

this


setResource(resource): this

Defined in: src/lib/services/ng-qubee.service.ts:666

Set the API resource to run the query against

string

Resource name (e.g. ‘users’ produces /users)

this


setSearch(search): this

Defined in: src/lib/services/ng-qubee.service.ts:682

Set the search term for full-text search (NestJS only)

Produces: search=term

string

The search term

this

If the active driver does not support search


totalPages(): number

Defined in: src/lib/services/ng-qubee.service.ts:697

Get the total number of pages reported by the most recent paginated response

number

The last page number

Throws when called before any paginate() has synced a value. For a non-throwing read in a template, read nest().isLastPageKnown first as a guard.

If state.isLastPageKnown is false (no paginated response has been synced yet)