Class: Query

Query

A fluent interace for creating queries against resourceful endpoints


new Query(query, sort [, sortModifier])

Parameters:
Name Type Argument Default Description
query string <nullable>

(private) Initial query string to append to.

sort string <nullable>

(private) What to sort the query on

sortModifier string <optional>
''

(private) Sort modifier. Either empty string or '-'

Source:
Requires:
Example
import { where, field } from '@pikselpalette/sequoia-js-client-sdk/lib/query';

endpoint.browse(where(field('startedAt').greaterThanOrEqualTo(2015))
                .and(field('tags').equalTo('showcase'))
                .fields('title', 'mediumSynopsis','duration', 'ref')
                .include('assets').page(1).perPage(24).orderByUpdatedAt().desc().count())
        .then(json => { ... });

Requires

Methods


addRelatedThroughFields(relationships)

Look through the relationships of a criteria, and include fields from through relationships - this makes it so that the end user shouldn't know or care that through relationships exist.

Parameters:
Name Type Description
relationships relationships

The relationship definitions that may require the addition of fields to support the graphical display of a through relationship

Source:
Returns:
Type
Query

and(query)

Concatenate a new query with the previous one

Parameters:
Name Type Description
query string

A query string to append (without leading ampersand). Usually returned from a call to field

Since:
  • 0.0.2
Source:
Returns:
Type
Query
Example
where(field('startedAt').greaterThanOrEqualTo(2015))
.and(field('tags').equalTo('showcase'))

asc()

Set order to ascending

Source:
Returns:
Type
Query

continue()

Appends continue=true to the query to initiate continuation paging

Source:
Returns:
Type
Query

count()

Will return totalCount on the payload

Source:
Returns:
Type
Query

desc()

Set order to descending

Source:
Returns:
Type
Query

fields(fieldName)

Appends fields=value1,value2 to the query

Parameters:
Name Type Argument Description
fieldName string <repeatable>

field(s) to return in the json response

Source:
Returns:
Type
Query
Example
where().fields('title', 'mediumSynopsis','duration', 'ref')
// appends `fields=title,mediumSynopsis,duration,ref` to the query

include(includes)

Appends include=value1,value2 to the query

Parameters:
Name Type Argument Description
includes string <repeatable>

includes(s) (linked resources) to return in the json response

Source:
Returns:
Type
Query
Example
where().include('assets', 'categories')
// appends `include=assets,categories` to the query

lang(value)

Appends lang=value to the query

Parameters:
Name Type Description
value string

ISO 639-1 code for the language you want results returned in

Source:
Returns:
Type
Query
Example
where().lang('de')
// appends `lang=de` to the query

orderBy()

Appends sort=[-]fieldName to the query, where [-] is toggled depending on the call to Query#asc or Query#desc

Source:
See:
Returns:
Type
Query

orderByCreatedAt()

Convenience method for ordering by 'createdAt'

Source:
See:
Returns:
Type
Query

orderByCreatedBy()

Convenience method for ordering by 'createdBy'

Source:
See:
Returns:
Type
Query

orderByName()

Convenience method for ordering by 'name'

Source:
See:
Returns:
Type
Query

orderByOwner()

Convenience method for ordering by 'owner'

Source:
See:
Returns:
Type
Query

orderByUpdatedAt()

Convenience method for ordering by 'updatedAt'

Source:
See:
Returns:
Type
Query

orderByUpdatedBy()

Convenience method for ordering by 'updatedBy'

Source:
See:
Returns:
Type
Query

page(value)

Appends page=value to the query

Parameters:
Name Type Description
value string | number

page of results to request

Source:
Returns:
Type
Query
Example
where().page(9)
// appends `page=9` to the query

perPage(value)

Appends perPage=value to the query

Parameters:
Name Type Description
value string | number

how many items to return per page of results

Source:
Returns:
Type
Query
Example
where().perPage(24)
// appends `perPage=24` to the query

toQueryString()

Turn the current Query into a string representation of a URI query

Source:
Returns:
Type
string