Skip to main content
Version: 8.1

EntitySchemaQuery class

Level: intermediate

The EntitySchemaQuery class builds queries to select records in a database.

Methods

abortQuery()

Aborts the query.

addAggregationSchemaColumn(columnPath, aggregationType, [columnAlias], aggregationEvalType)

Creates an instance of the Terrasoft.FunctionQueryColumn function column with the specified AGGREGATION type. Adds the instance to the query column collection.

Parameters

{String} columnPath

The path to the column to add, relative to rootSchema.

{Terrasoft.AggregationType} aggregationType

The aggregate function type.

Available values (Terrasoft.AggregationType)

AVG

The average of all elements. COUNT The number of elements.

MAX

The maximal element.

MIN

The minimal element.

NONE

The aggregate function type is undefined. SUM The sum of all elements.

{String} columnAlias

The column alias. Optional.

{Terrasoft.AggregationEvalType} aggregationEvalType

The aggregate function scope.

Available values (Terrasoft.AggregationEvalType)

NONE

The aggregate function scope is undefined.

ALL

Apply to all elements.

DISTINCT

Apply to unique values.

addColumn(column, [columnAlias], [config])

Creates an instance of the Terrasoft.EntityQueryColumn column. Adds the instance to the query column collection.

Parameters

{String/Terrasoft.BaseQueryColumn} column

The path to the column to add (relative to rootSchema) or an instance of the Terrasoft.BaseQueryColumn query column.

{String} columnAlias

The column alias. Optional.

config

The configuration object of the query column.

addDatePartFunctionColumn(columnPath, datePartType, [columnAlias])

Creates an instance of the Terrasoft.FunctionQueryColumn function column with the DATE_PART type. Adds the instance to the query column collection.

Parameters

{String/Terrasoft.BaseQueryColumn} column

The path to the column to add (relative to rootSchema) or an instance of the Terrasoft.BaseQueryColumn query column.

{String} columnAlias

The column alias. Optional.

{Object} config

The configuration object of the query column.

addDatePeriodMacrosColumn(macrosType, [macrosValue], [columnAlias])

Creates an instance of the Terrasoft.FunctionQueryColumn function column with the MACROS type that must be parameterized. Adds the instance to the query column collection. For example, the following N days, the third quarter of the year, etc.

Parameters

{String} columnPath

The path to the column to add, relative to rootSchema.

{Terrasoft.DatePartType} datePartType

The date part to use as the value.

Available values (Terrasoft.DatePartType)

NONE

Empty value.

DAY

Day.

WEEK

Week.

MONTH

Month.

YEAR

Year.

WEEK_DAY

Day of the week.

HOUR

Hour.

HOUR_MINUTE

Minute.

{String} columnAlias

The column alias. Optional.

addFunctionColumn(columnPath, functionType, [columnAlias])

Creates an instance of the Terrasoft.FunctionQueryColumn function column. Adds the instance to the query column collection.

Parameters

{String} columnPath

The path to the column to add, relative to rootSchema.

{Terrasoft.FunctionType} functionType

The function type.

Available values (Terrasoft.FunctionType)

NONE

The functional expression type is undefined.

MACROS

The insertion that uses a macro.

AGGREGATION

The aggregate function.

DATE_PART

The date part.

LENGTH

The value size, in bytes. Use with binary data.

{String} columnAlias

The column alias. Optional.

addMacrosColumn(macrosType, [columnAlias])

Creates an instance of the Terrasoft.FunctionQueryColumn function column with the MACROS type that does not need to be parameterized. For example, current month, current user, primary column, etc. Adds the instance to the query column collection.

Parameters

{Terrasoft.QueryMacrosType} macrosType

The column macro type.

Available values (Terrasoft.QueryMacrosType)

NONE

The macro type is undefined.

CURRENT_USER

The current user.

CURRENT_USER_CONTACT

The current user contact.

YESTERDAY

Yesterday.

TODAY

Today.

TOMORROW

Tomorrow.

PREVIOUS_WEEK

Previous week.

CURRENT_WEEK

Current week.

NEXT_WEEK

Next week.

PREVIOUS_MONTH

Previous month.

CURRENT_MONTH

Current month.

NEXT_MONTH

Next month.

PREVIOUS_QUARTER

Previous quarter.

CURRENT_QUARTER

Current quarter.

NEXT_QUARTER

Next quarter.

PREVIOUS_HALF_YEAR

Previous 6 months.

CURRENT_HALF_YEAR

Current 6 months.

NEXT_HALF_YEAR

Next 6 months.

PREVIOUS_YEAR

Previous year.

CURRENT_YEAR

Current year.

PREVIOUS_HOUR

Previous hour.

CURRENT_HOUR

Current hour.

NEXT_HOUR

Next hour.

NEXT_YEAR

Next year.

NEXT_N_DAYS

Next N days. Must be parameterized.

PREVIOUS_N_DAYS

Previous N days. Must be parameterized.

NEXT_N_HOURS

Next N hours. Must be parameterized.

PREVIOUS_N_HOURS

Previous N hours. Must be parameterized.

PRIMARY_COLUMN

The primary column.

PRIMARY_DISPLAY_COLUMN

The primary column for display.

PRIMARY_IMAGE_COLUMN

The primary column for image display.

{String} columnAlias

The column alias. Optional.

addParameterColumn(paramValue, paramDataType, [columnAlias])

Creates an instance of the Terrasoft.ParameterQueryColumn parameter column. Adds the instance to the query column collection.

Parameters

{Mixed} paramValue

The parameter value. Must correspond to the data type.

{Terrasoft.DataValueType} paramDataType

The parameter data type.

{String} columnAlias

The column alias. Optional.

createBetweenFilter(leftExpression, rightLessExpression, rightGreaterExpression)

Creates a Between filter instance.

Parameters

{Terrasoft.BaseExpression} leftExpression

The expression to check in the filter.

{Terrasoft.BaseExpression} rightLessExpression

The initial expression of the filtering scope.

{Terrasoft.BaseExpression} rightGreaterExpression

The final expression of the filtering scope.

createColumnBetweenFilterWithParameters(columnPath, lessParamValue, greaterParamValue, paramDataType)

Creates a Between filter instance to check if the column is within the specified scope.

Parameters

{String} columnPath

The path to the check column, relative to the rootSchema root schema.

{Mixed} lessParamValue

The initial value of the filter.

{Mixed} greaterParamValue

The final value of the filter.

{Terrasoft.DataValueType} paramDataType

The parameter data type.

createColumnFilterWithParameter(comparisonType, columnPath, paramValue, paramDataType)

Creates a Compare filter to instance to compare the column to a specified value.

Parameters

{Terrasoft.ComparisonType} comparisonType

The comparison operation type.

{String} columnPath

The path to the check column, relative to the rootSchema root schema.

{Mixed} paramValue

The parameter value.

{Terrasoft.DataValueType} paramDataType

The parameter data type.

createColumnInFilterWithParameters(columnPath, paramValues, paramDataType)

Creates an In filter instance to compare the value of a specified column to a parameter.

Parameters

{String} columnPath

The path to the check column, relative to the rootSchema root schema.

paramValues

The parameter value array.

{Terrasoft.DataValueType} paramDataType

The parameter data type.

createColumnIsNotNullFilter(columnPath)

Creates an IsNull filter instance to check the specified column.

Parameters

{String} columnPath

The path to the check column, relative to the rootSchema root schema.

createColumnIsNullFilter(columnPath)

Creates an IsNull filter instance to check the specified column.

Parameters

{String} columnPath

The path to the check column, relative to the rootSchema root schema.

createCompareFilter(comparisonType, leftExpression, rightExpression)

Creates a Compare filter instance.

Parameters

{Terrasoft.ComparisonType} comparisonType

The comparison operation type.

{Terrasoft.BaseExpression} leftExpression

The expression to check in the filter.

{Terrasoft.BaseExpression} rightExpression

The filtering expression.

createExistsFilter(columnPath)

Creates an Exists filter instance for the [Exists by the specified condition] type comparison. Sets the expression of the column at the specified path as the check value.

Parameters

{String} columnPath

The path to the column for whose expression to configure the filter.

createFilter(comparisonType, leftColumnPath, rightColumnPath)

Creates an instance of the Terrasoft.CompareFilter class filter to compare the values of two columns.

Parameters

{Terrasoft.ComparisonType} comparisonType

The comparison operation type.

{String} leftColumnPath

The path to the check column, relative to the rootSchema root schema.

{String} rightColumnPath

The path to the filter column, relative to the rootSchema root schema.

createFilterGroup()

Creates a filter group instance.

createInFilter(leftExpression, rightExpressions)

Creates an In filter instance.

Parameters

{Terrasoft.BaseExpression} leftExpression

The expression to check in the filter.

{Terrasoft.BaseExpression[]} rightExpressions

The array of expressions to compare to leftExpression.

createIsNotNullFilter(leftExpression)

Creates an IsNull filter instance.

Parameters

{Terrasoft.BaseExpression} leftExpression

The expression to check by the IS NOT NULL condition.

createIsNullFilter(leftExpression)

Creates an IsNull filter instance.

Parameters

{Terrasoft.BaseExpression} leftExpression

The expression to check by the IS NULL condition.

createNotExistsFilter(columnPath)

Creates an Exists filter instance for the [Does not exist by the specified condition] type comparison. Sets the expression of the column located at the specified path as the check value.

Parameters

{String} columnPath

The path to the column for whose expression to configure the filter.

createPrimaryDisplayColumnFilterWithParameter(comparisonType, paramValue, paramDataType)

Creates a filter object to compare the primary column to a parameter.

Parameters

{Terrasoft.ComparisonType} comparisonType

The comparison type.

{Mixed} paramValue

The parameter value.

{Terrasoft.DataValueType} paramDataType

The parameter data type.

destroy()

Deletes the object instance. If the object has already been deleted, writes an error message to the console. Calls the onDestroy virtual method to redefine in subclasses.

enablePrimaryColumnFilter(primaryColumnValue)

Enables filters by the primary key.

Parameters

{String/Number} primaryColumnValue

The value of the primary key.

error(message)

Writes an error message to the message log.

Parameters

{String} message

The error message to write to the message log.

execute(callback, scope)

The request to execute the query on the server.

Parameters

callback

The function to call after receiving the server response.

scope

The scope within which to call the callback function.

{Object} getDefSerializationInfo()

Returns the object that contains additional information for serialization.

getEntity(primaryColumnValue, callback, scope)

Returns the entity instance by the specified primaryColumnValue primary key. Calls the callback function within the scope scope after retrieving the data.

Parameters

{String/Number} primaryColumnValue

The value of the primary key.

callback

The function to call after receiving the server response.

scope

The scope within which to call the callback function.

getEntityCollection(callback, scope)

Returns the collection of entity instances that represent the query outcome. Calls the callback function within the scope scope after retrieving the data.

Parameters

callback

The function to call after receiving the server response.

scope

The scope within which to call the callback function.

{Object} getTypeInfo()

Returns the information about the element type.

log(message, [type])

Writes a message to the message log.

Parameters

{String|Object} message

The message to write to the message log.

{Terrasoft.LogMessageType} type

The type of the callback message log. Optional. By default, console.log. The Terrasoft.core.enums.LogMessageType enumeration specifies the available values.

onDestroy()

Deletes the event subscriptions and destroys the object.

serialize(serializationInfo)

Serializes the object in JSON.

Parameters

{String} serializationInfo

The results in JSON.

setSerializableProperty(serializableObject, propertyName)

Assigns the property name to the object if the object is not empty or not a function.

Parameters

serializableObject

The serializable object.

{String} propertyName

The property name.

warning(message)

Writes a warning message to the message log.

Parameters

{String} message

The message to write to the message log.