@neo4j/cypher-builder
Advanced tools
Comparing version 1.5.2 to 1.6.0
import type { CypherEnvironment } from "../Environment"; | ||
import type { Variable } from "../references/Variable"; | ||
import { Clause } from "./Clause"; | ||
import { WithCreate } from "./mixins/clauses/WithCreate"; | ||
import { WithMatch } from "./mixins/clauses/WithMatch"; | ||
import { WithMerge } from "./mixins/clauses/WithMerge"; | ||
import { WithReturn } from "./mixins/clauses/WithReturn"; | ||
import { WithUnwind } from "./mixins/clauses/WithUnwind"; | ||
import { WithWith } from "./mixins/clauses/WithWith"; | ||
export interface Call extends WithReturn, WithWith, WithUnwind { | ||
import { WithDelete } from "./mixins/sub-clauses/WithDelete"; | ||
import { WithRemove } from "./mixins/sub-clauses/WithRemove"; | ||
import { WithSet } from "./mixins/sub-clauses/WithSet"; | ||
export interface Call extends WithReturn, WithWith, WithUnwind, WithSet, WithRemove, WithDelete, WithMatch, WithCreate, WithMerge { | ||
} | ||
@@ -9,0 +15,0 @@ /** |
@@ -31,5 +31,11 @@ "use strict"; | ||
const Clause_1 = require("./Clause"); | ||
const WithCreate_1 = require("./mixins/clauses/WithCreate"); | ||
const WithMatch_1 = require("./mixins/clauses/WithMatch"); | ||
const WithMerge_1 = require("./mixins/clauses/WithMerge"); | ||
const WithReturn_1 = require("./mixins/clauses/WithReturn"); | ||
const WithUnwind_1 = require("./mixins/clauses/WithUnwind"); | ||
const WithWith_1 = require("./mixins/clauses/WithWith"); | ||
const WithDelete_1 = require("./mixins/sub-clauses/WithDelete"); | ||
const WithRemove_1 = require("./mixins/sub-clauses/WithRemove"); | ||
const WithSet_1 = require("./mixins/sub-clauses/WithSet"); | ||
const ImportWith_1 = require("./sub-clauses/ImportWith"); | ||
@@ -61,5 +67,7 @@ const mixin_1 = require("./utils/mixin"); | ||
const innerWithCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.importWith, env, { suffix: "\n" }); | ||
const removeCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.removeClause, env, { prefix: "\n" }); | ||
const setCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.setSubClause, env, { prefix: "\n" }); | ||
const inCallBlock = `${innerWithCypher}${subQueryStr}`; | ||
const nextClause = this.compileNextClause(env); | ||
return `CALL {\n${(0, pad_block_1.padBlock)(inCallBlock)}\n}${nextClause}`; | ||
return `CALL {\n${(0, pad_block_1.padBlock)(inCallBlock)}\n}${setCypher}${removeCypher}${nextClause}`; | ||
} | ||
@@ -69,3 +77,3 @@ }; | ||
exports.Call = Call = __decorate([ | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithWith_1.WithWith, WithUnwind_1.WithUnwind) | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithWith_1.WithWith, WithUnwind_1.WithUnwind, WithRemove_1.WithRemove, WithDelete_1.WithDelete, WithSet_1.WithSet, WithMatch_1.WithMatch, WithCreate_1.WithCreate, WithMerge_1.WithMerge) | ||
], Call); |
@@ -6,5 +6,9 @@ import type { CypherEnvironment } from "../Environment"; | ||
import { WithPathAssign } from "./mixins/WithPathAssign"; | ||
import { WithMerge } from "./mixins/clauses/WithMerge"; | ||
import { WithReturn } from "./mixins/clauses/WithReturn"; | ||
import { WithWith } from "./mixins/clauses/WithWith"; | ||
import { WithDelete } from "./mixins/sub-clauses/WithDelete"; | ||
import { WithRemove } from "./mixins/sub-clauses/WithRemove"; | ||
import { WithSet } from "./mixins/sub-clauses/WithSet"; | ||
export interface Create extends WithReturn, WithSet, WithPathAssign { | ||
export interface Create extends WithReturn, WithSet, WithPathAssign, WithWith, WithDelete, WithRemove, WithMerge { | ||
} | ||
@@ -18,4 +22,9 @@ /** | ||
constructor(pattern: NodeRef | Pattern); | ||
/** Add a {@link Create} clause | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/create/) | ||
*/ | ||
create(clause: Create): Create; | ||
create(pattern: NodeRef | Pattern): Create; | ||
/** @internal */ | ||
getCypher(env: CypherEnvironment): string; | ||
} |
@@ -26,2 +26,3 @@ "use strict"; | ||
}; | ||
var Create_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -33,3 +34,7 @@ exports.Create = void 0; | ||
const WithPathAssign_1 = require("./mixins/WithPathAssign"); | ||
const WithMerge_1 = require("./mixins/clauses/WithMerge"); | ||
const WithReturn_1 = require("./mixins/clauses/WithReturn"); | ||
const WithWith_1 = require("./mixins/clauses/WithWith"); | ||
const WithDelete_1 = require("./mixins/sub-clauses/WithDelete"); | ||
const WithRemove_1 = require("./mixins/sub-clauses/WithRemove"); | ||
const WithSet_1 = require("./mixins/sub-clauses/WithSet"); | ||
@@ -42,3 +47,3 @@ const Set_1 = require("./sub-clauses/Set"); | ||
*/ | ||
let Create = class Create extends Clause_1.Clause { | ||
let Create = Create_1 = class Create extends Clause_1.Clause { | ||
constructor(pattern) { | ||
@@ -54,2 +59,11 @@ super(); | ||
} | ||
create(clauseOrPattern) { | ||
if (clauseOrPattern instanceof Create_1) { | ||
this.addNextClause(clauseOrPattern); | ||
return clauseOrPattern; | ||
} | ||
const matchClause = new Create_1(clauseOrPattern); | ||
this.addNextClause(matchClause); | ||
return matchClause; | ||
} | ||
/** @internal */ | ||
@@ -60,9 +74,11 @@ getCypher(env) { | ||
const setCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.setSubClause, env, { prefix: "\n" }); | ||
const deleteStr = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.deleteClause, env, { prefix: "\n" }); | ||
const removeCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.removeClause, env, { prefix: "\n" }); | ||
const nextClause = this.compileNextClause(env); | ||
return `CREATE ${pathCypher}${patternCypher}${setCypher}${nextClause}`; | ||
return `CREATE ${pathCypher}${patternCypher}${setCypher}${removeCypher}${deleteStr}${nextClause}`; | ||
} | ||
}; | ||
exports.Create = Create; | ||
exports.Create = Create = __decorate([ | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithSet_1.WithSet, WithPathAssign_1.WithPathAssign) | ||
exports.Create = Create = Create_1 = __decorate([ | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithSet_1.WithSet, WithPathAssign_1.WithPathAssign, WithWith_1.WithWith, WithDelete_1.WithDelete, WithRemove_1.WithRemove, WithMerge_1.WithMerge) | ||
], Create); |
@@ -7,7 +7,13 @@ import type { CypherEnvironment } from "../Environment"; | ||
import type { Merge } from "./Merge"; | ||
import { WithCreate } from "./mixins/clauses/WithCreate"; | ||
import { WithMerge } from "./mixins/clauses/WithMerge"; | ||
import { WithReturn } from "./mixins/clauses/WithReturn"; | ||
import { WithWith } from "./mixins/clauses/WithWith"; | ||
import { WithDelete } from "./mixins/sub-clauses/WithDelete"; | ||
import { WithRemove } from "./mixins/sub-clauses/WithRemove"; | ||
import { WithSet } from "./mixins/sub-clauses/WithSet"; | ||
import type { DeleteClause } from "./sub-clauses/Delete"; | ||
import type { RemoveClause } from "./sub-clauses/Remove"; | ||
import type { SetClause } from "./sub-clauses/Set"; | ||
export interface Foreach extends WithWith { | ||
export interface Foreach extends WithWith, WithReturn, WithRemove, WithSet, WithDelete, WithCreate, WithMerge { | ||
} | ||
@@ -14,0 +20,0 @@ type ForeachClauses = Foreach | SetClause | RemoveClause | Create | Merge | DeleteClause; |
@@ -28,5 +28,12 @@ "use strict"; | ||
exports.Foreach = void 0; | ||
const compile_cypher_if_exists_1 = require("../utils/compile-cypher-if-exists"); | ||
const pad_block_1 = require("../utils/pad-block"); | ||
const Clause_1 = require("./Clause"); | ||
const WithCreate_1 = require("./mixins/clauses/WithCreate"); | ||
const WithMerge_1 = require("./mixins/clauses/WithMerge"); | ||
const WithReturn_1 = require("./mixins/clauses/WithReturn"); | ||
const WithWith_1 = require("./mixins/clauses/WithWith"); | ||
const WithDelete_1 = require("./mixins/sub-clauses/WithDelete"); | ||
const WithRemove_1 = require("./mixins/sub-clauses/WithRemove"); | ||
const WithSet_1 = require("./mixins/sub-clauses/WithSet"); | ||
const mixin_1 = require("./utils/mixin"); | ||
@@ -51,3 +58,6 @@ /** | ||
const foreachStr = [`FOREACH (${variableStr} IN ${listExpr} |`, (0, pad_block_1.padBlock)(mapClauseStr), `)`].join("\n"); | ||
return `${foreachStr}${nextClause}`; | ||
const setCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.setSubClause, env, { prefix: "\n" }); | ||
const deleteCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.deleteClause, env, { prefix: "\n" }); | ||
const removeCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.removeClause, env, { prefix: "\n" }); | ||
return `${foreachStr}${setCypher}${removeCypher}${deleteCypher}${nextClause}`; | ||
} | ||
@@ -57,3 +67,3 @@ }; | ||
exports.Foreach = Foreach = __decorate([ | ||
(0, mixin_1.mixin)(WithWith_1.WithWith) | ||
(0, mixin_1.mixin)(WithWith_1.WithWith, WithReturn_1.WithReturn, WithRemove_1.WithRemove, WithSet_1.WithSet, WithDelete_1.WithDelete, WithCreate_1.WithCreate, WithMerge_1.WithMerge) | ||
], Foreach); |
import type { CypherEnvironment } from "../Environment"; | ||
import { Pattern } from "../pattern/Pattern"; | ||
import type { NodeRef } from "../references/NodeRef"; | ||
import type { PropertyRef } from "../references/PropertyRef"; | ||
import { Clause } from "./Clause"; | ||
import { WithPathAssign } from "./mixins/WithPathAssign"; | ||
import { WithCreate } from "./mixins/clauses/WithCreate"; | ||
import { WithMerge } from "./mixins/clauses/WithMerge"; | ||
import { WithReturn } from "./mixins/clauses/WithReturn"; | ||
import { WithUnwind } from "./mixins/clauses/WithUnwind"; | ||
import { WithWith } from "./mixins/clauses/WithWith"; | ||
import { WithDelete } from "./mixins/sub-clauses/WithDelete"; | ||
import { WithRemove } from "./mixins/sub-clauses/WithRemove"; | ||
import { WithSet } from "./mixins/sub-clauses/WithSet"; | ||
import { WithWhere } from "./mixins/sub-clauses/WithWhere"; | ||
export interface Match extends WithReturn, WithWhere, WithSet, WithWith, WithPathAssign, WithDelete { | ||
export interface Match extends WithReturn, WithWhere, WithSet, WithWith, WithPathAssign, WithDelete, WithRemove, WithUnwind, WithCreate, WithMerge { | ||
} | ||
@@ -20,6 +23,4 @@ /** | ||
private pattern; | ||
private removeClause; | ||
private _optional; | ||
constructor(pattern: NodeRef | Pattern); | ||
remove(...properties: PropertyRef[]): this; | ||
/** Makes the clause an OPTIONAL MATCH | ||
@@ -37,2 +38,11 @@ * @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/) | ||
optional(): this; | ||
/** Add a {@link Match} clause | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/match/) | ||
*/ | ||
match(clause: Match): Match; | ||
match(pattern: NodeRef | Pattern): Match; | ||
/** Add an {@link OptionalMatch} clause | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/) | ||
*/ | ||
optionalMatch(pattern: NodeRef | Pattern): OptionalMatch; | ||
/** @internal */ | ||
@@ -39,0 +49,0 @@ getCypher(env: CypherEnvironment): string; |
@@ -26,2 +26,3 @@ "use strict"; | ||
}; | ||
var Match_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -33,8 +34,11 @@ exports.OptionalMatch = exports.Match = void 0; | ||
const WithPathAssign_1 = require("./mixins/WithPathAssign"); | ||
const WithCreate_1 = require("./mixins/clauses/WithCreate"); | ||
const WithMerge_1 = require("./mixins/clauses/WithMerge"); | ||
const WithReturn_1 = require("./mixins/clauses/WithReturn"); | ||
const WithUnwind_1 = require("./mixins/clauses/WithUnwind"); | ||
const WithWith_1 = require("./mixins/clauses/WithWith"); | ||
const WithDelete_1 = require("./mixins/sub-clauses/WithDelete"); | ||
const WithRemove_1 = require("./mixins/sub-clauses/WithRemove"); | ||
const WithSet_1 = require("./mixins/sub-clauses/WithSet"); | ||
const WithWhere_1 = require("./mixins/sub-clauses/WithWhere"); | ||
const Remove_1 = require("./sub-clauses/Remove"); | ||
const mixin_1 = require("./utils/mixin"); | ||
@@ -45,3 +49,3 @@ /** | ||
*/ | ||
let Match = class Match extends Clause_1.Clause { | ||
let Match = Match_1 = class Match extends Clause_1.Clause { | ||
constructor(pattern) { | ||
@@ -57,6 +61,2 @@ super(); | ||
} | ||
remove(...properties) { | ||
this.removeClause = new Remove_1.RemoveClause(this, properties); | ||
return this; | ||
} | ||
/** Makes the clause an OPTIONAL MATCH | ||
@@ -77,2 +77,19 @@ * @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/) | ||
} | ||
match(clauseOrPattern) { | ||
if (clauseOrPattern instanceof Match_1) { | ||
this.addNextClause(clauseOrPattern); | ||
return clauseOrPattern; | ||
} | ||
const matchClause = new Match_1(clauseOrPattern); | ||
this.addNextClause(matchClause); | ||
return matchClause; | ||
} | ||
/** Add an {@link OptionalMatch} clause | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/) | ||
*/ | ||
optionalMatch(pattern) { | ||
const matchClause = new OptionalMatch(pattern); | ||
this.addNextClause(matchClause); | ||
return matchClause; | ||
} | ||
/** @internal */ | ||
@@ -92,4 +109,4 @@ getCypher(env) { | ||
exports.Match = Match; | ||
exports.Match = Match = __decorate([ | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithWhere_1.WithWhere, WithSet_1.WithSet, WithWith_1.WithWith, WithPathAssign_1.WithPathAssign, WithDelete_1.WithDelete) | ||
exports.Match = Match = Match_1 = __decorate([ | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithWhere_1.WithWhere, WithSet_1.WithSet, WithWith_1.WithWith, WithPathAssign_1.WithPathAssign, WithDelete_1.WithDelete, WithRemove_1.WithRemove, WithUnwind_1.WithUnwind, WithCreate_1.WithCreate, WithMerge_1.WithMerge) | ||
], Match); | ||
@@ -96,0 +113,0 @@ /** |
@@ -6,7 +6,10 @@ import type { CypherEnvironment } from "../Environment"; | ||
import { WithPathAssign } from "./mixins/WithPathAssign"; | ||
import { WithCreate } from "./mixins/clauses/WithCreate"; | ||
import { WithReturn } from "./mixins/clauses/WithReturn"; | ||
import { WithWith } from "./mixins/clauses/WithWith"; | ||
import { WithDelete } from "./mixins/sub-clauses/WithDelete"; | ||
import { WithRemove } from "./mixins/sub-clauses/WithRemove"; | ||
import { WithSet } from "./mixins/sub-clauses/WithSet"; | ||
import type { OnCreateParam } from "./sub-clauses/OnCreate"; | ||
export interface Merge extends WithReturn, WithSet, WithPathAssign, WithDelete { | ||
export interface Merge extends WithReturn, WithSet, WithPathAssign, WithDelete, WithRemove, WithWith, WithCreate { | ||
} | ||
@@ -22,4 +25,9 @@ /** | ||
onCreate(...onCreateParams: OnCreateParam[]): this; | ||
/** Add a {@link Merge} clause | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/merge/) | ||
*/ | ||
merge(clause: Merge): Merge; | ||
merge(pattern: NodeRef | Pattern): Merge; | ||
/** @internal */ | ||
getCypher(env: CypherEnvironment): string; | ||
} |
@@ -26,2 +26,3 @@ "use strict"; | ||
}; | ||
var Merge_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -33,4 +34,7 @@ exports.Merge = void 0; | ||
const WithPathAssign_1 = require("./mixins/WithPathAssign"); | ||
const WithCreate_1 = require("./mixins/clauses/WithCreate"); | ||
const WithReturn_1 = require("./mixins/clauses/WithReturn"); | ||
const WithWith_1 = require("./mixins/clauses/WithWith"); | ||
const WithDelete_1 = require("./mixins/sub-clauses/WithDelete"); | ||
const WithRemove_1 = require("./mixins/sub-clauses/WithRemove"); | ||
const WithSet_1 = require("./mixins/sub-clauses/WithSet"); | ||
@@ -43,3 +47,3 @@ const OnCreate_1 = require("./sub-clauses/OnCreate"); | ||
*/ | ||
let Merge = class Merge extends Clause_1.Clause { | ||
let Merge = Merge_1 = class Merge extends Clause_1.Clause { | ||
constructor(pattern) { | ||
@@ -59,2 +63,11 @@ super(); | ||
} | ||
merge(clauseOrPattern) { | ||
if (clauseOrPattern instanceof Merge_1) { | ||
this.addNextClause(clauseOrPattern); | ||
return clauseOrPattern; | ||
} | ||
const matchClause = new Merge_1(clauseOrPattern); | ||
this.addNextClause(matchClause); | ||
return matchClause; | ||
} | ||
/** @internal */ | ||
@@ -65,11 +78,12 @@ getCypher(env) { | ||
const setCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.setSubClause, env, { prefix: "\n" }); | ||
const onCreateStr = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.onCreateClause, env, { prefix: "\n" }); | ||
const deleteStr = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.deleteClause, env, { prefix: "\n" }); | ||
const onCreateCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.onCreateClause, env, { prefix: "\n" }); | ||
const deleteCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.deleteClause, env, { prefix: "\n" }); | ||
const removeCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.removeClause, env, { prefix: "\n" }); | ||
const nextClause = this.compileNextClause(env); | ||
return `${mergeStr}${setCypher}${onCreateStr}${deleteStr}${nextClause}`; | ||
return `${mergeStr}${setCypher}${onCreateCypher}${removeCypher}${deleteCypher}${nextClause}`; | ||
} | ||
}; | ||
exports.Merge = Merge; | ||
exports.Merge = Merge = __decorate([ | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithSet_1.WithSet, WithPathAssign_1.WithPathAssign, WithDelete_1.WithDelete) | ||
exports.Merge = Merge = Merge_1 = __decorate([ | ||
(0, mixin_1.mixin)(WithReturn_1.WithReturn, WithSet_1.WithSet, WithPathAssign_1.WithPathAssign, WithDelete_1.WithDelete, WithRemove_1.WithRemove, WithWith_1.WithWith, WithCreate_1.WithCreate) | ||
], Merge); |
import type { CypherEnvironment } from "../Environment"; | ||
import { Clause } from "./Clause"; | ||
import { WithCreate } from "./mixins/clauses/WithCreate"; | ||
import { WithMatch } from "./mixins/clauses/WithMatch"; | ||
import { WithMerge } from "./mixins/clauses/WithMerge"; | ||
import { WithReturn } from "./mixins/clauses/WithReturn"; | ||
import { WithWith } from "./mixins/clauses/WithWith"; | ||
import { WithDelete } from "./mixins/sub-clauses/WithDelete"; | ||
import { WithRemove } from "./mixins/sub-clauses/WithRemove"; | ||
import { WithSet } from "./mixins/sub-clauses/WithSet"; | ||
import type { ProjectionColumn } from "./sub-clauses/Projection"; | ||
export interface Unwind extends WithWith, WithDelete { | ||
export interface Unwind extends WithWith, WithDelete, WithMatch, WithReturn, WithRemove, WithSet, WithCreate, WithMerge { | ||
} | ||
@@ -16,4 +22,10 @@ /** | ||
addColumns(...columns: Array<"*" | ProjectionColumn>): void; | ||
/** Append an {@link Unwind} clause. | ||
* @see [Cypher Documentation](https://neo4j.com/docs/cypher-manual/current/clauses/unwind/) | ||
*/ | ||
unwind(clause: Unwind): Unwind; | ||
unwind(...columns: Array<ProjectionColumn>): Unwind; | ||
/** @internal */ | ||
getCypher(env: CypherEnvironment): string; | ||
private addColumnsToUnwindClause; | ||
} |
@@ -26,2 +26,3 @@ "use strict"; | ||
}; | ||
var Unwind_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -31,4 +32,10 @@ exports.Unwind = void 0; | ||
const Clause_1 = require("./Clause"); | ||
const WithCreate_1 = require("./mixins/clauses/WithCreate"); | ||
const WithMatch_1 = require("./mixins/clauses/WithMatch"); | ||
const WithMerge_1 = require("./mixins/clauses/WithMerge"); | ||
const WithReturn_1 = require("./mixins/clauses/WithReturn"); | ||
const WithWith_1 = require("./mixins/clauses/WithWith"); | ||
const WithDelete_1 = require("./mixins/sub-clauses/WithDelete"); | ||
const WithRemove_1 = require("./mixins/sub-clauses/WithRemove"); | ||
const WithSet_1 = require("./mixins/sub-clauses/WithSet"); | ||
const Projection_1 = require("./sub-clauses/Projection"); | ||
@@ -40,3 +47,3 @@ const mixin_1 = require("./utils/mixin"); | ||
*/ | ||
let Unwind = class Unwind extends Clause_1.Clause { | ||
let Unwind = Unwind_1 = class Unwind extends Clause_1.Clause { | ||
constructor(...columns) { | ||
@@ -49,13 +56,32 @@ super(); | ||
} | ||
unwind(clauseOrColumn, ...columns) { | ||
if (clauseOrColumn instanceof Unwind_1) { | ||
this.addNextClause(clauseOrColumn); | ||
return clauseOrColumn; | ||
} | ||
return this.addColumnsToUnwindClause(clauseOrColumn, ...columns); | ||
} | ||
/** @internal */ | ||
getCypher(env) { | ||
const projectionStr = this.projection.getCypher(env); | ||
const deleteStr = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.deleteClause, env, { prefix: "\n" }); | ||
const deleteCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.deleteClause, env, { prefix: "\n" }); | ||
const setCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.setSubClause, env, { prefix: "\n" }); | ||
const removeCypher = (0, compile_cypher_if_exists_1.compileCypherIfExists)(this.removeClause, env, { prefix: "\n" }); | ||
const nextClause = this.compileNextClause(env); | ||
return `UNWIND ${projectionStr}${deleteStr}${nextClause}`; | ||
return `UNWIND ${projectionStr}${setCypher}${removeCypher}${deleteCypher}${nextClause}`; | ||
} | ||
addColumnsToUnwindClause(...columns) { | ||
if (!this.nextClause) { | ||
this.addNextClause(new Unwind_1()); | ||
} | ||
if (!(this.nextClause instanceof Unwind_1)) { | ||
throw new Error("Invalid Unwind statement"); | ||
} | ||
this.nextClause.addColumns(...columns); | ||
return this.nextClause; | ||
} | ||
}; | ||
exports.Unwind = Unwind; | ||
exports.Unwind = Unwind = __decorate([ | ||
(0, mixin_1.mixin)(WithWith_1.WithWith, WithDelete_1.WithDelete) | ||
exports.Unwind = Unwind = Unwind_1 = __decorate([ | ||
(0, mixin_1.mixin)(WithWith_1.WithWith, WithDelete_1.WithDelete, WithMatch_1.WithMatch, WithReturn_1.WithReturn, WithRemove_1.WithRemove, WithSet_1.WithSet, WithCreate_1.WithCreate, WithMerge_1.WithMerge) | ||
], Unwind); |
@@ -6,3 +6,7 @@ import type { CypherEnvironment } from "../Environment"; | ||
import { Clause } from "./Clause"; | ||
import { WithCreate } from "./mixins/clauses/WithCreate"; | ||
import { WithMatch } from "./mixins/clauses/WithMatch"; | ||
import { WithMerge } from "./mixins/clauses/WithMerge"; | ||
import { WithReturn } from "./mixins/clauses/WithReturn"; | ||
import { WithUnwind } from "./mixins/clauses/WithUnwind"; | ||
import { WithDelete } from "./mixins/sub-clauses/WithDelete"; | ||
@@ -12,3 +16,3 @@ import { WithOrder } from "./mixins/sub-clauses/WithOrder"; | ||
export type WithProjection = Variable | [Expr, string | Variable | Literal]; | ||
export interface With extends WithOrder, WithReturn, WithWhere, WithDelete { | ||
export interface With extends WithOrder, WithReturn, WithWhere, WithDelete, WithMatch, WithUnwind, WithCreate, WithMerge { | ||
} | ||
@@ -15,0 +19,0 @@ /** |
@@ -31,3 +31,7 @@ "use strict"; | ||
const Clause_1 = require("./Clause"); | ||
const WithCreate_1 = require("./mixins/clauses/WithCreate"); | ||
const WithMatch_1 = require("./mixins/clauses/WithMatch"); | ||
const WithMerge_1 = require("./mixins/clauses/WithMerge"); | ||
const WithReturn_1 = require("./mixins/clauses/WithReturn"); | ||
const WithUnwind_1 = require("./mixins/clauses/WithUnwind"); | ||
const WithDelete_1 = require("./mixins/sub-clauses/WithDelete"); | ||
@@ -85,3 +89,3 @@ const WithOrder_1 = require("./mixins/sub-clauses/WithOrder"); | ||
exports.With = With = With_1 = __decorate([ | ||
(0, mixin_1.mixin)(WithOrder_1.WithOrder, WithReturn_1.WithReturn, WithWhere_1.WithWhere, WithDelete_1.WithDelete) | ||
(0, mixin_1.mixin)(WithOrder_1.WithOrder, WithReturn_1.WithReturn, WithWhere_1.WithWhere, WithDelete_1.WithDelete, WithMatch_1.WithMatch, WithUnwind_1.WithUnwind, WithCreate_1.WithCreate, WithMerge_1.WithMerge) | ||
], With); |
{ | ||
"name": "@neo4j/cypher-builder", | ||
"version": "1.5.2", | ||
"version": "1.6.0", | ||
"description": "A programmatic API for building Cypher queries for Neo4j", | ||
@@ -48,4 +48,4 @@ "exports": "./dist/index.js", | ||
"@tsconfig/node16": "^16.1.0", | ||
"@types/jest": "29.5.6", | ||
"@types/node": "20.8.7", | ||
"@types/jest": "^29.5.6", | ||
"@types/node": "^20.8.9", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
@@ -55,11 +55,10 @@ "@typescript-eslint/parser": "^6.0.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"expect-type": "0.17.3", | ||
"jest": "29.7.0", | ||
"jest-extended": "4.0.2", | ||
"jest": "^29.7.0", | ||
"jest-extended": "^4.0.2", | ||
"neo4j-driver": "^5.9.2", | ||
"prettier": "^3.0.3", | ||
"ts-jest": "29.1.1", | ||
"typedoc": "0.25.2", | ||
"ts-jest": "^29.1.1", | ||
"typedoc": "^0.25.2", | ||
"typescript": "^5.1.6" | ||
} | ||
} |
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
381149
16
203
9318