@neo4j/cypher-builder
Version:
A programmatic API for building Cypher queries for Neo4j
235 lines (234 loc) • 7.97 kB
JavaScript
"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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.coalesce = coalesce;
exports.elementId = elementId;
exports.endNode = endNode;
exports.head = head;
exports.id = id;
exports.last = last;
exports.length = length;
exports.properties = properties;
exports.randomUUID = randomUUID;
exports.size = size;
exports.startNode = startNode;
exports.timestamp = timestamp;
exports.toBoolean = toBoolean;
exports.toBooleanOrNull = toBooleanOrNull;
exports.toFloat = toFloat;
exports.toFloatOrNull = toFloatOrNull;
exports.toInteger = toInteger;
exports.toIntegerOrNull = toIntegerOrNull;
exports.type = type;
exports.valueType = valueType;
exports.char_length = char_length;
exports.character_length = character_length;
exports.nullIf = nullIf;
const Raw_1 = require("../../clauses/Raw");
const CypherFunctions_1 = require("./CypherFunctions");
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-coalesce | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function coalesce(expr, ...optionalExpr) {
return new CypherFunctions_1.CypherFunction("coalesce", [expr, ...optionalExpr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-elementid | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function elementId(variable) {
return new CypherFunctions_1.CypherFunction("elementId", [variable]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-endnode | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function endNode(relationship) {
return new CypherFunctions_1.CypherFunction("endNode", [relationship]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-head | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function head(expr) {
return new CypherFunctions_1.CypherFunction("head", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-id | Cypher Documentation}
* @group Functions
* @category Scalar
* @deprecated Use {@link elementId} instead
*/
function id(variable) {
return new CypherFunctions_1.CypherFunction("id", [variable]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-last | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function last(expr) {
return new CypherFunctions_1.CypherFunction("last", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-length | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function length(path) {
return new CypherFunctions_1.CypherFunction("length", [path]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-properties | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function properties(expr) {
return new CypherFunctions_1.CypherFunction("properties", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-randomuuid | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function randomUUID() {
return new CypherFunctions_1.CypherFunction("randomUUID");
}
function size(expr) {
// Support for patterns in size() in Neo4j 4
// Using Raw to avoid adding Patterns to CypherFunction
const sizeParam = new Raw_1.Raw((env) => {
return env.compile(expr);
});
return new CypherFunctions_1.CypherFunction("size", [sizeParam]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-startnode | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function startNode(relationship) {
return new CypherFunctions_1.CypherFunction("startNode", [relationship]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-timestamp | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function timestamp() {
return new CypherFunctions_1.CypherFunction("timestamp");
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-toboolean | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function toBoolean(expr) {
return new CypherFunctions_1.CypherFunction("toBoolean", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-tobooleanornull | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function toBooleanOrNull(expr) {
return new CypherFunctions_1.CypherFunction("toBooleanOrNull", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-tofloat | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function toFloat(expr) {
return new CypherFunctions_1.CypherFunction("toFloat", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-tofloatornull | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function toFloatOrNull(expr) {
return new CypherFunctions_1.CypherFunction("toFloatOrNull", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-tointeger | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function toInteger(expr) {
return new CypherFunctions_1.CypherFunction("toInteger", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-tointegerornull | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function toIntegerOrNull(expr) {
return new CypherFunctions_1.CypherFunction("toIntegerOrNull", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-type | Cypher Documentation}
* @group Functions
* @category Scalar
*/
function type(relationship) {
return new CypherFunctions_1.CypherFunction("type", [relationship]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-valueType | Cypher Documentation}
* @group Functions
* @category Scalar
* @since Neo4j 5.13
*/
function valueType(expr) {
return new CypherFunctions_1.CypherFunction("valueType", [expr]);
}
/** Alias of size()
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-char_length | Cypher Documentation}
* @group Functions
* @category Scalar
* @since Neo4j 5.13
*/
function char_length(expr) {
return new CypherFunctions_1.CypherFunction("char_length", [expr]);
}
/** Alias of size()
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-character_length | Cypher Documentation}
* @group Functions
* @category Scalar
* @since Neo4j 5.13
*/
function character_length(expr) {
return new CypherFunctions_1.CypherFunction("character_length", [expr]);
}
/**
* @see {@link https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-nullIf | Cypher Documentation}
* @group Functions
* @category Scalar
* @since Neo4j 5.14
*/
function nullIf(expr1, expr2) {
return new CypherFunctions_1.CypherFunction("nullIf", [expr1, expr2]);
}