Skip to content

Commit

Permalink
Change typings for compileCypherIfExists
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykoala committed Jun 8, 2023
1 parent 25f7017 commit cc144e1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/utils/compile-cypher-if-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
*/

import type { CypherEnvironment } from "../Environment";
import { Clause } from "../clauses/Clause";
import { Expr } from "../types";
import { compileCypher } from "./compile-cypher";
import { CypherCompilable } from "../types";

/** Compiles the cypher of an element, if the resulting cypher is not empty adds a prefix */
export function compileCypherIfExists(
element: Expr | Clause | undefined,
element: CypherCompilable | undefined,
env: CypherEnvironment,
options: { prefix?: string; suffix?: string } = {}
{ prefix = "", suffix = "" }: { prefix?: string; suffix?: string } = {}
): string {
if (!element) return "";
return compileCypher(element, env, options);
const cypher = element.getCypher(env);
if (!cypher) return "";
return `${prefix}${cypher}${suffix}`;
}

0 comments on commit cc144e1

Please sign in to comment.