UNPKG

@neo4j/cypher-builder

Version:

A programmatic API for building Cypher queries for Neo4j

65 lines (64 loc) 2.79 kB
"use strict"; /* * Copyright (c) "Neo4j" * Neo4j Sweden AB [http://neo4j.com] * * This file is part of Neo4j. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoadCSV = void 0; const Clause_1 = require("./Clause"); const WithCallProcedure_1 = require("./mixins/clauses/WithCallProcedure"); 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 WithWhere_1 = require("./mixins/sub-clauses/WithWhere"); const mixin_1 = require("./utils/mixin"); /** * @see {@link https://neo4j.com/docs/cypher-manual/current/clauses/load-csv/ | Cypher Documentation} * @group Clauses */ let LoadCSV = class LoadCSV extends Clause_1.Clause { constructor(url, alias) { super(); this._withHeaders = false; this.url = url; this.alias = alias; } withHeaders() { this._withHeaders = true; return this; } /** * @internal */ getCypher(env) { const aliasStr = this.alias.getCypher(env); const nextClause = this.compileNextClause(env); const withHeadersStr = this._withHeaders ? "WITH HEADERS " : ""; return `LOAD CSV ${withHeadersStr}FROM "${this.url}" AS ${aliasStr}${nextClause}`; } }; exports.LoadCSV = LoadCSV; exports.LoadCSV = LoadCSV = __decorate([ (0, mixin_1.mixin)(WithReturn_1.WithReturn, WithCreate_1.WithCreate, WithMerge_1.WithMerge, WithWith_1.WithWith, WithWhere_1.WithWhere, WithCallProcedure_1.WithCallProcedure) ], LoadCSV);