@neo4j/cypher-builder
Advanced tools
Comparing version 1.10.2 to 1.10.3
import type { CypherEnvironment } from "../../Environment"; | ||
import type { Variable } from "../../references/Variable"; | ||
import type { CypherCompilable, Expr } from "../../types"; | ||
import type { Variable } from "../../references/Variable"; | ||
import { MapExpr } from "./MapExpr"; | ||
@@ -17,3 +17,4 @@ /** Represents a Map projection | ||
private projection; | ||
constructor(variable: Variable, projection?: string[], extraValues?: Record<string, Expr>); | ||
private isStar; | ||
constructor(variable: Variable, projection?: "*" | string[], extraValues?: Record<string, Expr>); | ||
set(values: Record<string, Expr> | string): void; | ||
@@ -20,0 +21,0 @@ /** Converts the Map projection expression into a normal Map expression |
@@ -22,6 +22,6 @@ "use strict"; | ||
exports.MapProjection = void 0; | ||
const escape_1 = require("../../utils/escape"); | ||
const is_string_1 = require("../../utils/is-string"); | ||
const serialize_map_1 = require("../../utils/serialize-map"); | ||
const MapExpr_1 = require("./MapExpr"); | ||
const is_string_1 = require("../../utils/is-string"); | ||
const escape_1 = require("../../utils/escape"); | ||
/** Represents a Map projection | ||
@@ -38,4 +38,11 @@ * @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/syntax/maps/#cypher-map-projection) | ||
this.extraValues = new Map(); | ||
this.isStar = false; | ||
this.variable = variable; | ||
this.projection = projection; | ||
if (projection === "*") { | ||
this.isStar = true; | ||
this.projection = []; | ||
} | ||
else { | ||
this.projection = projection; | ||
} | ||
this.setExtraValues(extraValues); | ||
@@ -76,3 +83,7 @@ } | ||
const extraValuesStr = (0, serialize_map_1.serializeMap)(env, this.extraValues, true); | ||
const projectionStr = this.projection.map((p) => `.${(0, escape_1.escapeProperty)(p)}`).join(", "); | ||
const escapedColumns = this.projection.map((p) => `.${(0, escape_1.escapeProperty)(p)}`); | ||
if (this.isStar) { | ||
escapedColumns.unshift(".*"); | ||
} | ||
const projectionStr = escapedColumns.join(", "); | ||
const commaStr = extraValuesStr && projectionStr ? ", " : ""; | ||
@@ -79,0 +90,0 @@ return `${variableStr} { ${projectionStr}${commaStr}${extraValuesStr} }`; |
{ | ||
"name": "@neo4j/cypher-builder", | ||
"version": "1.10.2", | ||
"version": "1.10.3", | ||
"description": "A programmatic API for building Cypher queries for Neo4j", | ||
@@ -5,0 +5,0 @@ "exports": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
395783
9661