File

src/api/core/queries/selectQuery.ts

Description

Query object specialized for select statements. For TypeScript users it implements a generic type T that represents your dataset (defaults to any). This object is generated automatically from the Dataset object, never to be instantiated directly.

Example

```typescript

  • dataModule.dataset("posts")
  • .select()
  • .where(field => field("title").isLike("test"))
  • .execute();
  • ```

Extends

FilterableQuery

Example

Index

Methods

Methods

Public limit
limit(limit: number)

Limit the operation for the first n records

Parameters :
Name Type Optional Description
limit number No

number limit records amount

Public offset
offset(offset: number)

Offset selection with the offset records

Parameters :
Name Type Optional Description
offset number No

number offset amount

Public related
related(resourceName: R, callback: (q: RelatedQuery>) => void)
Type parameters :
  • R

Allow to populate related resource fields

Parameters :
Name Type Optional Default value Description
resourceName R No

Related resource

callback function No (related) => { // @ts-ignore // TODO typescript issue, upgrade TS this.query.fields.push(resourceName); return related; }

Pass RelatedQuery object to the callback

Example :
dataset("posts")
.select()
.related("comments", comments => comments.fields("author", "date", "text"))
execute();
Public sortAsc
sortAsc(fields: K[])
Type parameters :
  • K

Sort ascendent the response that will represent the affected data

Parameters :
Name Type Optional Description
fields K[] No

fields names to sort with

Public sortAsc
sortAsc(...fields: K[])
Type parameters :
  • K
Parameters :
Name Type Optional
fields K[] No
Public sortAsc
sortAsc(field: K, ...fields: K[])
Type parameters :
  • K
Parameters :
Name Type Optional
field K No
fields K[] No
Public sortDesc
sortDesc(fields: K[])
Type parameters :
  • K

Sort decedent the response that will represent the affected data

Parameters :
Name Type Optional Description
fields K[] No

fields names to sort with

Public sortDesc
sortDesc(...fields: K[])
Type parameters :
  • K
Parameters :
Name Type Optional
fields K[] No
Public sortDesc
sortDesc(field: K, ...fields: K[])
Type parameters :
  • K
Parameters :
Name Type Optional
field K No
fields K[] No
Public where
where(filter: IFilteringCriterion | IFilteringCriterionCallback)

Filter the dataset rows with some conditions where the operation will be applied

Parameters :
Name Type Optional Description
filter IFilteringCriterion<T> | IFilteringCriterionCallback<T> No

Filtering criteria or a callback that returns a filtering criteria with the conditions

Public fields
fields(fields: Array)

Select the fields to be returned at the response that represent the affected data Aggregation functions can be provided as an object: { fn: aggFn, col: string }

Parameters :
Name Type Optional Description
fields Array<Extract | IAggField> No

fields names or aggregation object

Public fields
fields(...fields: Array)
Parameters :
Name Type Optional
fields Array<Extract | IAggField> No
Public fields
fields(field: K | IAggField, ...fields: Array)
Type parameters :
  • K
Parameters :
Name Type Optional
field K | IAggField<T> No
fields Array<K | IAggField> No
Public fields
fields(fields: Array)

Select the fields to be returned at the response that represent the affected data Aggregation functions can be provided as an object: { fn: aggFn, col: string }

Parameters :
Name Type Optional Description
fields Array<Extract | IAggField> No

fields names or aggregation object

Public fields
fields(...fields: Array)
Parameters :
Name Type Optional
fields Array<Extract | IAggField> No
Public fields
fields(field: K | IAggField, ...fields: Array)
Type parameters :
  • K
Parameters :
Name Type Optional
field K | IAggField<T> No
fields Array<K | IAggField> No

result-matching ""

    No results matching ""