Skip to main content
Version: Next

AnalyticsQueryBuilder

age-schema-client v0.5.0


age-schema-client / AnalyticsQueryBuilder

Class: AnalyticsQueryBuilder<T>

Defined in: src/query/analytics.ts:314

Analytics query builder class

Specialized query builder for aggregation and analytics operations on graph data

Extends

Extended by

Type Parameters

Type Parameter
T extends SchemaDefinition

Constructors

Constructor

new AnalyticsQueryBuilder<T>(
schema,
queryExecutor,
graphName): AnalyticsQueryBuilder<T>;

Defined in: src/query/analytics.ts:322

Create a new analytics query builder

Parameters

ParameterTypeDefault valueDescription
schemaTundefinedSchema definition
queryExecutorQueryExecutorundefinedQuery executor
graphNamestring'default'Graph name

Returns

AnalyticsQueryBuilder<T>

Overrides

QueryBuilder.constructor

Methods

match()

Implementation of the match method for analytics

Call Signature

match<L>(label, alias): IMatchClause<T, L>;

Defined in: src/query/analytics.ts:333

Add MATCH clause for a vertex

Type Parameters
Type Parameter
L extends string | number | symbol
Parameters
ParameterType
labelL
aliasstring
Returns

IMatchClause<T, L>

Overrides

QueryBuilder.match

Call Signature

match<E>(
sourceAlias,
edgeLabel,
targetAlias): IEdgeMatchClause<T>;

Defined in: src/query/analytics.ts:338

Add MATCH clause for an edge between two previously matched vertices

Type Parameters
Type Parameter
E extends string | number | symbol
Parameters
ParameterType
sourceAliasstring
edgeLabelE
targetAliasstring
Returns

IEdgeMatchClause<T>

Overrides

QueryBuilder.match

Call Signature

match<E>(
sourceAlias,
edgeLabel,
targetAlias,
edgeAlias): IEdgeMatchClause<T>;

Defined in: src/query/analytics.ts:347

Add MATCH clause for an edge between two previously matched vertices with an edge alias

Type Parameters
Type Parameter
E extends string | number | symbol
Parameters
ParameterType
sourceAliasstring
edgeLabelE
targetAliasstring
edgeAliasstring
Returns

IEdgeMatchClause<T>

Overrides

QueryBuilder.match


groupBy()

groupBy(...fields): this;

Defined in: src/query/analytics.ts:398

Group results by specified fields

Parameters

ParameterTypeDescription
...fieldsstring[]Fields to group by

Returns

this

This analytics query builder

Throws

Error if no RETURN clause is specified before groupBy


windowFunction()

windowFunction(
functionType,
resultAlias,
options): this;

Defined in: src/query/analytics.ts:419

Add a window function to the query

Parameters

ParameterTypeDescription
functionTypestringWindow function type
resultAliasstringAlias for the window function result
optionsWindowFunctionOptionsWindow function options

Returns

this

This analytics query builder


rowNumber()

rowNumber(resultAlias, options): this;

Defined in: src/query/analytics.ts:485

Add ROW_NUMBER window function

Parameters

ParameterTypeDescription
resultAliasstringAlias for the result
optionsWindowFunctionOptionsWindow function options

Returns

this

This analytics query builder


rank()

rank(resultAlias, options): this;

Defined in: src/query/analytics.ts:496

Add RANK window function

Parameters

ParameterTypeDescription
resultAliasstringAlias for the result
optionsWindowFunctionOptionsWindow function options

Returns

this

This analytics query builder


denseRank()

denseRank(resultAlias, options): this;

Defined in: src/query/analytics.ts:507

Add DENSE_RANK window function

Parameters

ParameterTypeDescription
resultAliasstringAlias for the result
optionsWindowFunctionOptionsWindow function options

Returns

this

This analytics query builder


where()

where(condition, params): this;

Defined in: src/query/builder.ts:234

Add WHERE clause

Parameters

ParameterTypeDescription
conditionstringCondition expression
paramsRecord<string, any>Parameters

Returns

this

This query builder

Inherited from

QueryBuilder.where


return()

return(...expressions): this;

Defined in: src/query/builder.ts:278

Add RETURN clause

Parameters

ParameterTypeDescription
...expressionsstring[]Return expressions

Returns

this

This query builder

Inherited from

QueryBuilder.return


orderBy()

orderBy(expression, direction): this;

Defined in: src/query/builder.ts:290

Add ORDER BY clause

Parameters

ParameterTypeDefault valueDescription
expressionstringundefinedExpression to order by
directionOrderDirectionOrderDirection.ASCOrder direction

Returns

this

This query builder

Inherited from

QueryBuilder.orderBy


limit()

limit(count): this;

Defined in: src/query/builder.ts:311

Add LIMIT clause

Parameters

ParameterTypeDescription
countnumberLimit count

Returns

this

This query builder

Inherited from

QueryBuilder.limit


skip()

skip(count): this;

Defined in: src/query/builder.ts:322

Add SKIP clause

Parameters

ParameterTypeDescription
countnumberSkip count

Returns

this

This query builder

Inherited from

QueryBuilder.skip


with()

with(...expressions): this;

Defined in: src/query/builder.ts:333

Add WITH clause

Parameters

ParameterTypeDescription
...expressionsstring[]With expressions

Returns

this

This query builder

Inherited from

QueryBuilder.with


unwind()

unwind(expression, alias): this;

Defined in: src/query/builder.ts:345

Add UNWIND clause

Parameters

ParameterTypeDescription
expressionstringExpression to unwind
aliasstringAlias for unwound items

Returns

this

This query builder

Inherited from

QueryBuilder.unwind


withParam()

withParam(name, value): this;

Defined in: src/query/builder.ts:357

Add a parameter to the query

Parameters

ParameterTypeDescription
namestringParameter name
valueanyParameter value

Returns

this

This query builder

Inherited from

QueryBuilder.withParam


setParam()

setParam(key, value): Promise<AnalyticsQueryBuilder<T>>;

Defined in: src/query/builder.ts:373

Set a parameter in the age_params temporary table

This method inserts a parameter into the age_params temporary table using an INSERT ON CONFLICT UPDATE statement. The parameter can then be referenced in a Cypher query using the get_age_param() function.

Parameters

ParameterTypeDescription
keystringParameter key
valueanyParameter value (will be converted to JSON)

Returns

Promise<AnalyticsQueryBuilder<T>>

This query builder

Inherited from

QueryBuilder.setParam


withParamFunction()

withParamFunction(functionName, alias): this;

Defined in: src/query/builder.ts:398

Add a WITH clause that calls a function to get parameters

This is specifically for Apache AGE compatibility, as it requires parameters to be passed via a function call in a WITH clause.

Parameters

ParameterTypeDescription
functionNamestringFully qualified function name (e.g., 'schema.get_params')
aliasstringAlias for the function result (e.g., 'params')

Returns

this

This query builder

Inherited from

QueryBuilder.withParamFunction


withAgeParam()

withAgeParam(key, alias): this;

Defined in: src/query/builder.ts:413

Add a WITH clause that calls the get_age_param function

This method adds a WITH clause that calls the get_age_param function to retrieve a parameter from the age_params temporary table.

Parameters

ParameterTypeDescription
keystringParameter key to retrieve
aliasstringAlias for the parameter in the query

Returns

this

This query builder

Inherited from

QueryBuilder.withAgeParam


withAllAgeParams()

withAllAgeParams(alias): this;

Defined in: src/query/builder.ts:428

Add a WITH clause that calls the get_all_age_params function

This method adds a WITH clause that calls the get_all_age_params function to retrieve all parameters from the age_params temporary table.

Parameters

ParameterTypeDefault valueDescription
aliasstring'params'Alias for the parameters object in the query

Returns

this

This query builder

Inherited from

QueryBuilder.withAllAgeParams


execute()

execute<R>(options): QueryBuilderResult<R>;

Defined in: src/query/builder.ts:441

Execute the query

Type Parameters

Type ParameterDefault type
Rany

Parameters

ParameterTypeDescription
optionsQueryExecutionOptionsQuery execution options

Returns

QueryBuilderResult<R>

Query result

Throws

Error if query validation fails

Inherited from

QueryBuilder.execute


reset()

reset(): this;

Defined in: src/query/builder.ts:584

Reset the query builder state

Returns

this

This query builder

Inherited from

QueryBuilder.reset


toCypher()

toCypher(): string;

Defined in: src/query/builder.ts:595

Get the Cypher query string

Returns

string

Cypher query string

Inherited from

QueryBuilder.toCypher


getParameters()

getParameters(): Record<string, any>;

Defined in: src/query/builder.ts:607

Get the query parameters

Returns

Record<string, any>

Query parameters

Inherited from

QueryBuilder.getParameters


validateSchema()

validateSchema(): string[];

Defined in: src/query/builder.ts:624

Validate the query against the schema

Returns

string[]

Validation errors, if any

Inherited from

QueryBuilder.validateSchema


validateQuery()

validateQuery(): string[];

Defined in: src/query/builder.ts:707

Validate the query for variable references and other semantic issues

Returns

string[]

Validation errors with helpful suggestions

Inherited from

QueryBuilder.validateQuery