query

This type represents a representation of a database query result set.

It provides language specific methods to access columnar data, both as value lists and within iterative loops

Query Methods

addColumn(columnName=[string], datatype=[any], array=[array])

Adds a column to a query and populates its rows with the contents of a one-dimensional array.

Arguments:

Argument
Type
Required
Default

columnName

string

true

null

datatype

any

false

object

array

array

false

[]

addRow(rowData=[any])

Return new query

Arguments:

Argument
Type
Required
Default

rowData

any

false

null

append(query2=[query])

This function clears the query

Arguments:

Argument
Type
Required
Default

query2

query

true

null

clear()

This function clears the query

columnArray()

This function returns the column array of a query.

columnCount()

This function returns the number of columns in a query

columnData(columnName=[string])

Returns the data in a query column.

Arguments:

Argument
Type
Required
Default

columnName

string

true

null

columnExists(column=[string])

This function returns true if the column exists in the query

Arguments:

Argument
Type
Required
Default

column

string

true

null

columnList()

This function returns the delimited column list of a query.

currentRow()

Returns the current row number

deleteColumn(column=[string])

Deletes a column within a query object.

Arguments:

Argument
Type
Required
Default

column

string

true

null

deleteRow(row=[integer])

This function deletes a row from the query

Arguments:

Argument
Type
Required
Default

row

integer

true

null

duplicate(deep=[boolean])

Duplicates an object - either shallow or deep

Arguments:

Argument
Type
Required
Default

deep

boolean

false

true

each(callback=[function:Consumer], parallel=[boolean], maxThreads=[integer])

Iterates over query rows and passes each row per iteration to a callback function

Arguments:

Argument
Type
Required
Default

callback

function:Consumer

true

null

parallel

boolean

false

false

maxThreads

integer

false

null

every(closure=[function:Predicate], parallel=[boolean], maxThreads=[integer])

Executes a callback/closure against every row in a query and returns true if the callback/closure returned true for every row.

Arguments:

Argument
Type
Required
Default

closure

function:Predicate

true

null

parallel

boolean

false

false

maxThreads

integer

false

null

filter(callback=[function:Predicate], parallel=[boolean], maxThreads=[integer])

Filters query rows specified in filter criteria

Arguments:

Argument
Type
Required
Default

callback

function:Predicate

true

null

parallel

boolean

false

false

maxThreads

integer

false

null

getCell(column_name=[string], row_number=[integer])

This function maps the query to a new query.

Arguments:

Argument
Type
Required
Default

column_name

string

true

null

row_number

integer

false

null

getResult()

Returns the metadata of a query.

getRow(rowNumber=[integer])

Returns the cells of a query row as a structure

Arguments:

Argument
Type
Required
Default

rowNumber

integer

true

null

insertAt(value=[query], position=[numeric])

Inserts a query data into another query at a specific position

Arguments:

Argument
Type
Required
Default

value

query

true

null

position

numeric

true

null

isEmpty()

Determine whether a given value is empty.

We check for emptiness of anything that can be casted to: Array, Struct, Query, or String.

keyExists(key=[string])

This function returns true if the key exists in the query

Arguments:

Argument
Type
Required
Default

key

string

true

null

len()

Returns the absolute value of a number

map(callback=[function:Function], parallel=[boolean], maxThreads=[integer])

This function maps the query to a new query.

Arguments:

Argument
Type
Required
Default

callback

function:Function

true

null

parallel

boolean

false

false

maxThreads

integer

false

null

prepend(query2=[query])

Adds a query to the beginning of another query

Arguments:

Argument
Type
Required
Default

query2

query

true

null

recordCount()

This function returns the number of records in a query

reduce(callback=[function:BiFunction], initialValue=[any])

This function reduces the query to a single value.

Arguments:

Argument
Type
Required
Default

callback

function:BiFunction

true

null

initialValue

any

true

null

reverse()

This function reverses the query data

rowData(rowNumber=[integer])

Returns the cells of a query row as a structure

Arguments:

Argument
Type
Required
Default

rowNumber

integer

true

null

rowSwap(source=[numeric], destination=[numeric])

In a query object, swap the record in the sourceRow with the record from the destinationRow.

Arguments:

Argument
Type
Required
Default

source

numeric

true

null

destination

numeric

true

null

setCell(column=[string], value=[any], row=[integer])

Sets a cell to a value.

Arguments:

Argument
Type
Required
Default

column

string

true

null

value

any

true

null

row

integer

false

null

setRow(rowNumber=[integer], rowData=[any])

Adds or updates a row in a query based on the provided row data and position.

Arguments:

Argument
Type
Required
Default

rowNumber

integer

false

0

rowData

any

true

null

slice(offset=[integer], length=[integer])

Returns a subset of rows from an existing query

Arguments:

Argument
Type
Required
Default

offset

integer

true

null

length

integer

false

0

some(callback=[function:Predicate], parallel=[boolean], maxThreads=[integer], initialValue=[any])

This function calls a given closure/function with every element in a given query and returns true, if one of the closure calls returns true

Arguments:

Argument
Type
Required
Default

callback

function:Predicate

true

null

parallel

boolean

false

false

maxThreads

integer

false

null

initialValue

any

false

null

sort(sortFunc=[function:Comparator])

Sorts array elements.

Arguments:

Argument
Type
Required
Default

sortFunc

function:Comparator

true

null

toArrayOfStructs()

Convert this query to an array of structs.

toJSON(queryFormat=[string], useSecureJSONPrefix=[string], useCustomSerializer=[boolean])

Converts a BoxLang variable into a JSON (JavaScript Object Notation) string.

Arguments:

Argument
Type
Required
Default

queryFormat

string

false

row

useSecureJSONPrefix

string

false

false

useCustomSerializer

boolean

false

null

toModifiable()

Convert an array, struct or query to its Modifiable counterpart.

toUnmodifiable()

Convert an array, struct or query to its Unmodifiable counterpart.

Examples

Last updated

Was this helpful?