@decaf-ts/core
Version:
Core persistence module for the decaf framework
41 lines (40 loc) • 1.55 kB
TypeScript
import { OperatorParser } from "./types";
/**
* @description
* Map of supported operators to their corresponding parser functions.
*
* @summary
* The `OperatorsMap` defines a collection of operator names as keys
* (such as `Equals`, `LessThan`, `Between`, etc.), each mapped to a
* function that constructs a `Condition` object for that operator.
* These functions translate query clauses into concrete condition
* builders, enabling dynamic query construction from method names.
*
* @template T The type of the field values used in conditions.
*
* @param f {string} - The field name the condition applies to.
* @param v1 {any} - The value to compare the field against or the lower bound value for range-based operators.
* @param v2 {any} - The upper bound value for range-based operators.
*
* @return {Condition<any>} A condition object representing the operator applied to the field.
*
* @function OperatorsMap
*
* @mermaid
* sequenceDiagram
* participant Client as Caller
* participant Map as OperatorsMap
* participant Parser as OperatorParser
* participant Cond as Condition
*
* Client->>Map: Request operator parser ("Between", field, v1, v2)
* Map->>Parser: Call corresponding operator function
* Parser->>Cond: Condition.attribute(field)
* Cond-->>Parser: Condition instance
* Parser->>Cond: Apply gte(v1)
* Parser->>Cond: Apply and(lte(v2))
* Parser-->>Client: Return built Condition
*
* @memberOf module:query
*/
export declare const OperatorsMap: Record<string, OperatorParser>;