Reference·JavaScript · @bimworks/jssdkJavaScript

QueryColumns

Class in @bimworks/jssdk.

API catalogue · @bimworks/jssdk · Class

TypeScript#
class QueryColumns

Reads query records through the columns table of their answer (QueryRecords.columns). Read a value by its alias here, never as record[alias]: an alias names a column, and where the value is written is the server's business.

JavaScript#
const walls = await bim.query(models, "GET attribute.Name AS name, quantity.*.NetVolume AS volume WHERE type = IFCWALL");
const rows = QueryColumns.byLabel(walls);                  // [{name: {...}, volume: {...}}, ...]
const volume = QueryColumns.get(walls[0], "volume", walls.columns);

Members#

Member Kind Description
constructor Method
byLabel Method The records as objects keyed by column label; a relation's or COLLECT's value as an array of such objects
entries Method Every value of a column in a record (more than one when its path holds "*" or crosses an array)
find Method The top level column with this alias, else this label, else this text
get Method The value of the column called name (QueryColumns.find) in a record
leaves Method The columns as a table shows them: one per value, a relation's items as columns of their own
of Method The columns table of an answer: records.columns, or the columns of a raw answer; null when it has none
value Method The value of a column in a record as the server wrote it: undefined when absent, an array when there are several

constructor#

TypeScript#
constructor()

byLabel#

TypeScript#
static byLabel(records: readonly (unknown)[], columns?: (QueryColumn)[] | null): (Record<string, unknown>)[]

The records as objects keyed by column label; a relation's or COLLECT's value as an array of such objects

Parameters#

Name Type Description
records readonly (unknown)[]
columns (QueryColumn)[] | null

entries#

TypeScript#
static entries(record: unknown, column: QueryColumn | null | undefined): ({ key: string | null; value: unknown })[]

Every value of a column in a record (more than one when its path holds "*" or crosses an array)

Parameters#

Name Type Description
record unknown
column QueryColumn | null | undefined

find#

TypeScript#
static find(columns: (QueryColumn)[] | null | undefined, name: string): QueryColumn | undefined

The top level column with this alias, else this label, else this text

Parameters#

Name Type Description
columns (QueryColumn)[] | null | undefined
name string

get#

TypeScript#
static get(record: unknown, name: string, columns: (QueryColumn)[] | null | undefined): unknown

The value of the column called name (QueryColumns.find) in a record

Parameters#

Name Type Description
record unknown
name string
columns (QueryColumn)[] | null | undefined

leaves#

TypeScript#
static leaves(columns: (QueryColumn)[] | null | undefined): (QueryLeafColumn)[]

The columns as a table shows them: one per value, a relation's items as columns of their own

Parameters#

Name Type Description
columns (QueryColumn)[] | null | undefined

of#

TypeScript#
static of(recordsOrAnswer: unknown): (QueryColumn)[] | null

The columns table of an answer: records.columns, or the columns of a raw answer; null when it has none

Parameters#

Name Type Description
recordsOrAnswer unknown

value#

TypeScript#
static value(record: unknown, column: QueryColumn | null | undefined): unknown

The value of a column in a record as the server wrote it: undefined when absent, an array when there are several

Parameters#

Name Type Description
record unknown
column QueryColumn | null | undefined