UNPKG

@neo4j/cypher-builder

Version:

A programmatic API for building Cypher queries for Neo4j

41 lines (40 loc) 1.22 kB
"use strict"; /* * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] */ Object.defineProperty(exports, "__esModule", { value: true }); exports.QuantifiedPath = void 0; const pad_block_1 = require("../../utils/pad-block"); const PathAssign_1 = require("../PathAssign"); /** * @group Patterns */ class QuantifiedPath { patterns = []; constructor(...patterns) { this.patterns = patterns; } assignTo(variable) { return new PathAssign_1.PathAssign(this, variable); } /** * @internal */ getCypher(env) { const patternsStrings = this.patterns.map((pattern) => { return pattern.getCypher(env); }); const firstPattern = patternsStrings.shift() ?? ""; if (patternsStrings.length > 0) { const remainingPatternsString = this.getRemainingPatternsString(patternsStrings); return `${firstPattern}\n${remainingPatternsString}`; } return firstPattern; } getRemainingPatternsString(patternStrings) { const remainingPatternsStr = patternStrings.join("\n"); return (0, pad_block_1.padBlock)(remainingPatternsStr, 6); } } exports.QuantifiedPath = QuantifiedPath;