skipcheck

TM1 client · Docs · Queries

ODataQuery

import { ODataQuery } from "@skipcheck/tm1-client";

Used in the walkthroughs Connect and list your cubes, Read and write cells, Run a process and read its result, Test your code against a real TM1, Add TM1 to a Spring Boot application.

OData query options: $select, $expand (with nested options), $filter, $orderby, $top, $skip, $count, custom options such as TM1's !sandbox, and parameter aliases. Immutable: each method returns a new query.

const query = ODataQuery.none()
  .select("Name", "Type")
  .expand("Hierarchies", (h) => h.select("Name").top(5))
  .filter(Filter.startsWith(ODataProperty.of("Name"), "Q"))
  .toQueryString();
// $select=Name,Type&$expand=Hierarchies($select=Name;$top=5)&$filter=startswith(Name,'Q'), each value encoded

Options are written in a fixed order, lowercase with $ as OData 4.0 requires, and each value is percent-encoded once by toQueryString. Nested options inside $expand are separated by ;.

Members

none staticNo options.
selectAdds properties to $select, after any already selected.
expandExpands a navigation property, with nested options applied to what's there for it already.
filterSets $filter, replacing any set before.
orderByAdds an ascending $orderby key, after any keys already added.
orderByDescendingAdds a descending $orderby key, after any keys already added.
topSets $top.
skipSets $skip.
withCountSets $count=true.
optionWith a value, sets a custom option, such as TM1's !sandbox; without, reads it (or undefined).
optionSets a custom query option, such as TM1's !sandbox, replacing any set before; the value is given unencoded.
optionWith a value, sets a custom query option, such as TM1's !sandbox, replacing any set before; the value is given unencoded.
aliasA parameter alias's value.
isEmptyTrue if this query has no options.
customOptions@internal
parametersEvery option, unencoded, in order.
toQueryStringThe encoded query string, without ?.
equalsWhether other has the same options.
toStringThe query unencoded, for logs and messages.

none

static
static none(): ODataQuery

No options: the server's default response.

select

select(...properties: (string | ODataProperty)[]): ODataQuery

Adds properties to $select, after any already selected. Like every option here it's an instance method, so it works the same at the top level and inside expand.

expand

expand(navigation: string | ODataProperty, options: (q: ODataQuery) => ODataQuery = (q) => q): ODataQuery

Expands a navigation property, with nested options applied to what's there for it already.

filter

filter(filter: Filter): ODataQuery

Sets $filter, replacing any set before.

orderBy

orderBy(property: string | ODataProperty): ODataQuery

Adds an ascending $orderby key, after any keys already added.

orderByDescending

orderByDescending(property: string | ODataProperty): ODataQuery

Adds a descending $orderby key, after any keys already added.

top

top(n: number): ODataQuery

Sets $top: at most this many items. @throws RangeError if n is negative

skip

skip(n: number): ODataQuery

Sets $skip: skip this many items first. @throws RangeError if n is negative

withCount

withCount(): ODataQuery

Sets $count=true: include the total number of matching items.

option

option(name: string): string | undefined

With a value, sets a custom option, such as TM1's !sandbox; without, reads it (or undefined).

option

option(name: string, value: string): ODataQuery

Sets a custom query option, such as TM1's !sandbox, replacing any set before; the value is given unencoded. Custom options must not start with $ or @. @throws RangeError if name isn't a valid custom option name

option

option(name: string, value?: string): ODataQuery | string | undefined

With a value, sets a custom query option, such as TM1's !sandbox, replacing any set before; the value is given unencoded. With a name alone, reads that option's value. Custom options must not start with $ or @. @throws RangeError if name isn't a valid custom option name

alias

alias(alias: ODataPath.Alias, literalOrJson: string): ODataQuery

A parameter alias's value: Fn(p=@p) with ?@p=….

isEmpty

isEmpty(): boolean

True if this query has no options.

customOptions

customOptions(): readonly Pair[]

@internal

parameters

parameters(): Pair[]

Every option, unencoded, in order.

toQueryString

toQueryString(): string

The encoded query string, without ?.

equals

equals(other: unknown): boolean

Whether other has the same options.

toString

toString(): string

The query unencoded, for logs and messages.