Skip to content

Commit

Permalink
docs: jsdoc added for wrapWhereClauseInParenthesis and mergeWhereClauses
Browse files Browse the repository at this point in the history
  • Loading branch information
nktnet1 committed Nov 28, 2024
1 parent 731cf5b commit 1845693
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/modules/components/common_components/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,15 @@ export class Common {
return new Promise(resolve => setTimeout(resolve, time));
}

/**
* Wraps the given `WhereClause` in parentheses - useful for merging.
*
* @param {WhereClause} clause - The `WhereClause` to be wrapped.
* @returns {{beginClause: WhereClause, endClause: WhereClause}} An object
* containing the `beginClause` (the wrapped version of the input
* `clause`) and the `endClause` (the last clause where the right
* side of the expression ends with a close parenthesis).
*/
private static wrapWhereClauseInParenthesis(clause: WhereClause): { beginClause: WhereClause, endClause: WhereClause } {
const clone = JSON.parse(JSON.stringify(clause)) as WhereClause;
clone.left.openParen = (clone.left.openParen ?? 0) + 1;
Expand All @@ -1871,6 +1880,17 @@ export class Common {
return { beginClause: clone, endClause: current };
}

/**
* Merges two `WhereClause` objects into a single clause, joining them with
* a logical operator (defaults AND).
*
* @param {WhereClause} [where1] - First clause to merge
* @param {WhereClause} [where2] - Second clause to merge
* @param {LogicalOperator} [operator='AND'] - Operator for joing clauses
*
* @returns {WhereClause|undefined} A new `WhereClause` that represents the
* merged expression, or `undefined` if neither clauses were provided.
*/
static mergeWhereClauses(
where1?: WhereClause,
where2?: WhereClause,
Expand Down

0 comments on commit 1845693

Please sign in to comment.