import { Entity } from '../binding'; import { Node } from './Node'; import type { EntityManager } from '../EntityManager'; import { Class } from '../util'; /** * An Operator saves the state of a combined query */ export class Operator extends Node { /** * The operator used to join the child queries */ public readonly operator: string; /** * The child Node of this query, it is always one */ public readonly childes: Node[]; /** * @param entityManager The owning entity manager of this query * @param resultClass The query result class * @param operator The operator used to join the childes * @param childes The childes to join */ constructor(entityManager: EntityManager, resultClass: Class, operator: string, childes: Node[]) { super(entityManager, resultClass); this.operator = operator; this.childes = childes; } toJSON(): { [operator: string]: Node[] } { const json: { [operator: string]: Node[] } = {}; json[this.operator] = this.childes; return json; } }