Options
All
  • Public
  • Public/Protected
  • All
Menu

A condition that can operate against a single "primitive" field of a model or item.

member

field The field of some record to test against.

member

operator The equality or comparison operator to use.

member

operands The operands for the equality/comparison check.

Hierarchy

  • FieldCondition

Index

Constructors

constructor

  • new FieldCondition(field: string, operator: string, operands: string[]): FieldCondition

Properties

field

field: string

operands

operands: string[]

operator

operator: string

Methods

copy

fetch

  • Not implemented. Not needed. GroupCondition instead consumes FieldConditions and transforms them into legacy predicates. (For now.)

    Parameters

    • storage: StorageAdapter

      N/A. If ever implemented, the storage adapter to query.

    Returns Promise<Record<string, any>[]>

    N/A. If ever implemented, return items from storage that match.

matches

negated

  • Produces a new condition (FieldCondition or GroupCondition) that matches the opposite of this condition.

    Intended to be used when applying De Morgan's Law, which can be done to produce more efficient queries against the storage layer if a negation appears in the query tree.

    For example:

    1. name.eq('robert') becomes name.ne('robert')
    2. price.between(100, 200) becomes m => m.or(m => [m.price.lt(100), m.price.gt(200)])

    Parameters

    • model: ModelMeta<any>

      The model meta to use when construction a new GroupCondition for cases where the negation requires multiple FieldCondition's.

    Returns FieldCondition | GroupCondition

toAST

  • toAST(): object
  • Produces a tree structure similar to a graphql condition. The returned structure is "dumb" and is intended for another query/condition generation mechanism to interpret, such as the cloud or storage query builders.

    E.g.,

    {
        "name": {
            "eq": "robert"
        }
    }

    Returns object

    • [this.field]: object
      • [this.operator]: string | string[]

validate

  • validate(): void