@neo4j/cypher-builder
Advanced tools
Comparing version 0.1.9 to 0.1.10
import type { CypherEnvironment } from "../Environment"; | ||
import type { CypherCompilable } from "../types"; | ||
import type { CypherCompilable, Expr } from "../types"; | ||
import type { Reference } from "./Reference"; | ||
@@ -11,7 +11,7 @@ import type { Variable } from "./Variable"; | ||
private _variable; | ||
private _property; | ||
constructor(variable: Reference, property: string); | ||
private propertyPath; | ||
constructor(variable: Reference, ...properties: Array<string | Expr>); | ||
get variable(): Variable; | ||
/** Access individual property via the PropertyRef class, using the dot notation */ | ||
property(path: string): PropertyRef; | ||
property(prop: string | Expr): PropertyRef; | ||
/** | ||
@@ -21,3 +21,4 @@ * @hidden | ||
getCypher(env: CypherEnvironment): string; | ||
private getPropertyCypher; | ||
} | ||
//# sourceMappingURL=PropertyRef.d.ts.map |
@@ -27,5 +27,5 @@ "use strict"; | ||
class PropertyRef { | ||
constructor(variable, property) { | ||
constructor(variable, ...properties) { | ||
this._variable = variable; | ||
this._property = property; | ||
this.propertyPath = properties; | ||
} | ||
@@ -36,4 +36,4 @@ get variable() { | ||
/** Access individual property via the PropertyRef class, using the dot notation */ | ||
property(path) { | ||
return new PropertyRef(this.variable, `${this._property}.${path}`); | ||
property(prop) { | ||
return new PropertyRef(this._variable, ...this.propertyPath, prop); | ||
} | ||
@@ -45,6 +45,16 @@ /** | ||
const variableStr = this.variable.getCypher(env); | ||
return `${variableStr}.${this._property}`; | ||
const propStr = this.propertyPath.map((prop) => this.getPropertyCypher(prop, env)).join(""); | ||
return `${variableStr}${propStr}`; | ||
} | ||
getPropertyCypher(prop, env) { | ||
if (typeof prop === "string") { | ||
return `.${prop}`; | ||
} | ||
else { | ||
const exprStr = prop.getCypher(env); | ||
return `[${exprStr}]`; | ||
} | ||
} | ||
} | ||
exports.PropertyRef = PropertyRef; | ||
//# sourceMappingURL=PropertyRef.js.map |
import { PropertyRef } from "./PropertyRef"; | ||
import { ListIndex } from "../expressions/list/ListIndex"; | ||
import type { CypherCompilable } from "../types"; | ||
import type { CypherCompilable, Expr } from "../types"; | ||
import type { CypherEnvironment } from "../Environment"; | ||
@@ -14,3 +14,3 @@ /** Represents a reference that will be kept in the environment */ | ||
/** Access individual property via the PropertyRef class, using the dot notation */ | ||
property(path: string): PropertyRef; | ||
property(path: string | Expr): PropertyRef; | ||
index(index: number): ListIndex; | ||
@@ -17,0 +17,0 @@ } |
{ | ||
"name": "@neo4j/cypher-builder", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "Neo4j Cypher query builder", | ||
@@ -36,10 +36,10 @@ "exports": "./dist/index.js", | ||
"devDependencies": { | ||
"@types/jest": "29.2.5", | ||
"@types/node": "18.11.10", | ||
"@types/jest": "29.4.0", | ||
"@types/node": "18.11.17", | ||
"expect-type": "0.15.0", | ||
"jest": "29.3.1", | ||
"ts-jest": "29.0.3", | ||
"typedoc": "0.23.23", | ||
"typescript": "4.9.4" | ||
"jest": "29.4.1", | ||
"ts-jest": "29.0.5", | ||
"typedoc": "0.23.24", | ||
"typescript": "4.9.5" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
378037
6046