UNPKG

@neo4j/cypher-builder

Version:

A programmatic API for building Cypher queries for Neo4j

249 lines (248 loc) 8.33 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.abs = abs; exports.ceil = ceil; exports.floor = floor; exports.cypherIsNaN = cypherIsNaN; exports.rand = rand; exports.round = round; exports.sign = sign; exports.e = e; exports.exp = exp; exports.log = log; exports.log10 = log10; exports.sqrt = sqrt; exports.acos = acos; exports.asin = asin; exports.atan = atan; exports.atan2 = atan2; exports.cos = cos; exports.cot = cot; exports.degrees = degrees; exports.haversin = haversin; exports.pi = pi; exports.radians = radians; exports.sin = sin; exports.tan = tan; const Cypher_1 = require("../../Cypher"); const filter_truthy_1 = require("../../utils/filter-truthy"); const CypherFunctions_1 = require("./CypherFunctions"); /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-abs | Cypher Documentation} * @group Functions * @category Math */ function abs(expr) { return new CypherFunctions_1.CypherFunction("abs", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-ceil | Cypher Documentation} * @group Functions * @category Math */ function ceil(expr) { return new CypherFunctions_1.CypherFunction("ceil", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-floor | Cypher Documentation} * @group Functions * @category Math */ function floor(expr) { return new CypherFunctions_1.CypherFunction("floor", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-isnan | Cypher Documentation} * @group Functions * @category Math */ function cypherIsNaN(expr) { return new CypherFunctions_1.CypherFunction("isNaN", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-rand | Cypher Documentation} * @group Functions * @category Math */ function rand() { return new CypherFunctions_1.CypherFunction("rand"); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-round | Cypher Documentation} * @group Functions * @category Math */ function round(expr, precision, mode) { let precisionExpr; const modeExpr = mode ? new Cypher_1.Literal(mode) : undefined; if (typeof precision === "number") { precisionExpr = new Cypher_1.Literal(precision); } else { precisionExpr = precision; } return new CypherFunctions_1.CypherFunction("round", (0, filter_truthy_1.filterTruthy)([expr, precisionExpr, modeExpr])); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-sign | Cypher Documentation} * @group Functions * @category Math */ function sign(expr) { return new CypherFunctions_1.CypherFunction("sign", [expr]); } /** Cypher function `e()` that returns the returns the base of the natural logarithm. * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-e | Cypher Documentation} * @group Functions * @category Math */ function e() { return new CypherFunctions_1.CypherFunction("e"); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-exp | Cypher Documentation} * @group Functions * @category Math */ function exp(expr) { return new CypherFunctions_1.CypherFunction("exp", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-log | Cypher Documentation} * @group Functions * @category Math */ function log(expr) { return new CypherFunctions_1.CypherFunction("log", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-log10 | Cypher Documentation} * @group Functions * @category Math */ function log10(expr) { return new CypherFunctions_1.CypherFunction("log10", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-logarithmic/#functions-sqrt | Cypher Documentation} * @group Functions * @category Math */ function sqrt(expr) { return new CypherFunctions_1.CypherFunction("sqrt", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-acos | Cypher Documentation} * @group Functions * @category Math */ function acos(expr) { return new CypherFunctions_1.CypherFunction("acos", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-asin | Cypher Documentation} * @group Functions * @category Math */ function asin(expr) { return new CypherFunctions_1.CypherFunction("asin", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-atan | Cypher Documentation} * @group Functions * @category Math */ function atan(expr) { return new CypherFunctions_1.CypherFunction("atan", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-atan2 | Cypher Documentation} * @group Functions * @category Math */ function atan2(expr) { return new CypherFunctions_1.CypherFunction("atan2", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-cos | Cypher Documentation} * @group Functions * @category Math */ function cos(expr) { return new CypherFunctions_1.CypherFunction("cos", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-cot | Cypher Documentation} * @group Functions * @category Math */ function cot(expr) { return new CypherFunctions_1.CypherFunction("cot", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-degrees | Cypher Documentation} * @group Functions * @category Math */ function degrees(expr) { return new CypherFunctions_1.CypherFunction("degrees", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-haversin | Cypher Documentation} * @group Functions * @category Math */ function haversin(expr) { return new CypherFunctions_1.CypherFunction("haversin", [expr]); } /** 3.141592653589793 * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-pi | Cypher Documentation} * @see https://www.piday.org/ * @group Functions * @category Math */ function pi() { return new CypherFunctions_1.CypherFunction("pi"); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-radians | Cypher Documentation} * @group Functions * @category Math */ function radians(expr) { return new CypherFunctions_1.CypherFunction("radians", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-sin | Cypher Documentation} * @group Functions * @category Math */ function sin(expr) { return new CypherFunctions_1.CypherFunction("sin", [expr]); } /** * @see {@link https://neo4j.com/docs/cypher-manual/current/functions/mathematical-trigonometric/#functions-tan | Cypher Documentation} * @group Functions * @category Math */ function tan(expr) { return new CypherFunctions_1.CypherFunction("tan", [expr]); }