Class Operator<T>Abstract

Represents the low level abstraction of query generation that is responsible for the creation of queries themselves.

Operators are ment to be stateless and held as singleton instances, as they can be shared without any issues. This library uses the OperatorService to store the singleton instances, but you can use your own solution, or instantiate them multiple times if you prefer.

T type of arguments this Operator can generate queries from

Type Parameters

  • T

Hierarchy (view full)

Constructors

Properties

INPUT_PLACEHOLDER: "" = ''

Represents the placeholder "block" in operator display names.

Accessors

Methods

  • Simple implementation of query generation. Will not be suitable for all Operator derivatives.

    Escapes the first argument from the args array, calls the [query()]Operator#query function for each keyword and combines the results with an OR operator.

    Parameters

    • pfqlKeywords: string[]
    • args: T[]
    • escapeArgs: boolean = true
    • wrapInQuotes: boolean = true

    Returns Query

    query that wos constructed with the given arguments and keywords. Returns an empty query if no arguments are provided.

  • The name template is used when generating search GUI, and so the arity of the operator should match the number of INPUT_PLACEHOLDER constant occurrences in the returned array.

    Returns string[]

    an array of translation paths that represent the operator name, as it should be displayed to the user. The INPUT_PLACEHOLDER constant (or any falsy value) can be used to place visual input placeholder blocks in the operator name where user input is expected.

  • Creates a PFQL query with the provided arguments.

    Parameters

    • pfqlKeyword: string

      PFQL keyword for the field you want to query

    • arg: string

      The value that you want to query the property for

    • operator: string

      The PFQL operator you want to use to query the field.

    Returns string

    combines the input strings by this pattern: [pfqlKeyword] [operator] [arg]