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 static | No options. |
select | Adds properties to $select, after any already selected. |
expand | Expands a navigation property, with nested options applied to what's there for it already. |
filter | Sets $filter, replacing any set before. |
orderBy | Adds an ascending $orderby key, after any keys already added. |
orderByDescending | Adds a descending $orderby key, after any keys already added. |
top | Sets $top. |
skip | Sets $skip. |
withCount | Sets $count=true. |
option | With a value, sets a custom option, such as TM1's !sandbox; without, reads it (or undefined). |
option | Sets a custom query option, such as TM1's !sandbox, replacing any set before; the value is given unencoded. |
option | With a value, sets a custom query option, such as TM1's !sandbox, replacing any set before; the value is given unencoded. |
alias | A parameter alias's value. |
isEmpty | True if this query has no options. |
customOptions | @internal |
parameters | Every option, unencoded, in order. |
toQueryString | The encoded query string, without ?. |
equals | Whether other has the same options. |
toString | The query unencoded, for logs and messages. |
none
staticstatic none(): ODataQueryNo options: the server's default response.
select
select(...properties: (string | ODataProperty)[]): ODataQueryAdds 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): ODataQueryExpands a navigation property, with nested options applied to what's there for it already.
filter
filter(filter: Filter): ODataQuerySets $filter, replacing any set before.
orderBy
orderBy(property: string | ODataProperty): ODataQueryAdds an ascending $orderby key, after any keys already added.
orderByDescending
orderByDescending(property: string | ODataProperty): ODataQueryAdds a descending $orderby key, after any keys already added.
top
top(n: number): ODataQuerySets $top: at most this many items. @throws RangeError if n is negative
skip
skip(n: number): ODataQuerySets $skip: skip this many items first. @throws RangeError if n is negative
withCount
withCount(): ODataQuerySets $count=true: include the total number of matching items.
option
option(name: string): string | undefinedWith a value, sets a custom option, such as TM1's !sandbox; without, reads it (or undefined).
option
option(name: string, value: string): ODataQuerySets 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 | undefinedWith 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): ODataQueryA parameter alias's value: Fn(p=@p) with ?@p=….
isEmpty
isEmpty(): booleanTrue if this query has no options.
customOptions
customOptions(): readonly Pair[]@internal
parameters
parameters(): Pair[]Every option, unencoded, in order.
toQueryString
toQueryString(): stringThe encoded query string, without ?.
equals
equals(other: unknown): booleanWhether other has the same options.
toString
toString(): stringThe query unencoded, for logs and messages.