@neo4j/cypher-builder
Version:
A programmatic API for building Cypher queries for Neo4j
37 lines (36 loc) • 734 B
JavaScript
;
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ListIndex = void 0;
exports.listIndex = listIndex;
/**
* @group Lists
*/
class ListIndex {
value;
index;
/**
* @internal
*/
constructor(variable, index) {
this.value = variable;
this.index = index;
}
/** @internal */
getCypher(env) {
return `${this.value.getCypher(env)}[${this.index}]`;
}
}
exports.ListIndex = ListIndex;
/** Adds a index access operator (`[ ]`) to an expression
* @example
* ```cypher
* collect(var)[0]
* ```
*/
function listIndex(expr, index) {
return new ListIndex(expr, index);
}