UNPKG

@neo4j/cypher-builder

Version:

A programmatic API for building Cypher queries for Neo4j

48 lines (47 loc) 1.24 kB
"use strict"; /* * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] */ Object.defineProperty(exports, "__esModule", { value: true }); exports.NamedVariable = exports.Variable = void 0; const ListIndex_1 = require("../expressions/list/ListIndex"); const escape_1 = require("../utils/escape"); const PropertyRef_1 = require("./PropertyRef"); /** Represents a variable * @group Variables */ class Variable { /** * @internal */ prefix = "var"; /** Access individual property via the PropertyRef class */ property(...path) { return new PropertyRef_1.PropertyRef(this, ...path); } // NOTE: duplicate in ListExpr /* Adds a index access operator (`[ ]`) to the variable */ index(index) { return (0, ListIndex_1.listIndex)(this, index); } /** @internal */ getCypher(env) { const id = env.getReferenceId(this); return (0, escape_1.escapeVariable)(id); } } exports.Variable = Variable; /** * Represents a variable with a explicit name * @group Variables */ class NamedVariable extends Variable { id; constructor(name) { super(); this.id = name; this.prefix = ""; } } exports.NamedVariable = NamedVariable;