Skip to main content
Version: Next

QuerySingle<T>

A QuerySingle is a Query which follows relations that should be unique between data types (0..1 and 1..1 cardinalities). It returns the instance related to the origin, following the specified relation(s).

It acts as a syntactic sugar to avoid having a query result structure and get the first value out of it.

A QuerySingle is immutable.

Type Parameters

Type Parameter
T extends CloudObject

Constructors

new QuerySingle()

new QuerySingle<T>(): QuerySingle<T>

Returns

QuerySingle<T>

Methods

from()

static from<T>(object): QuerySingle<T>

Create a query single from a single node. See Query.from

Type Parameters

Type Parameter
T extends CloudObject

Parameters

ParameterTypeDescription
objectInstanceOrTagstarting node for the graph query single

Returns

QuerySingle<T>

new query single only accepting 0..1 relations


cast()

cast<S>(type): QuerySingle<S>

See Query.cast()

Type Parameters

Type Parameter
S extends CloudObject

Parameters

ParameterTypeDescription
typeClass<S>the new type

Returns

QuerySingle<S>

query single on a node of the specified type


execute()

execute(): Promise<T>

Execute the query single, see Query.execute()

Returns

Promise<T>

promise containing the single result or null


executeFromCache()

executeFromCache(): T

Execute the query single on the local data cloud, see Query.executeFromCache()

Returns

T

single result value or null


follow()

follow<D>(relation): QuerySingle<D>

Follow a 0..1 relation See Query.follow()

Type Parameters

Type Parameter
D extends CloudObject

Parameters

ParameterTypeDescription
relationRelation<T, D>relation to next node

Returns

QuerySingle<D>

new query single with follow operation