UNPKG

@firebase/firestore

Version:

The Cloud Firestore component of the Firebase JS SDK.

53 lines (52 loc) 2.29 kB
/** * @license * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { CompositeFilter, Filter } from '../core/filter'; /** * Provides utility functions that help with boolean logic transformations needed for handling * complex filters used in queries. */ /** * The `in` filter is only a syntactic sugar over a disjunction of equalities. For instance: `a in * [1,2,3]` is in fact `a==1 || a==2 || a==3`. This method expands any `in` filter in the given * input into a disjunction of equality filters and returns the expanded filter. */ export declare function computeInExpansion(filter: Filter): Filter; /** * Given a composite filter, returns the list of terms in its disjunctive normal form. * * <p>Each element in the return value is one term of the resulting DNF. For instance: For the * input: (A || B) && C, the DNF form is: (A && C) || (B && C), and the return value is a list * with two elements: a composite filter that performs (A && C), and a composite filter that * performs (B && C). * * @param filter the composite filter to calculate DNF transform for. * @return the terms in the DNF transform. */ export declare function getDnfTerms(filter: CompositeFilter): Filter[]; export declare function computeDistributedNormalForm(filter: Filter): Filter; export declare function applyDistribution(lhs: Filter, rhs: Filter): Filter; /** * Applies the associativity property to the given filter and returns the resulting filter. * * <ul> * <li>A | (B | C) == (A | B) | C == (A | B | C) * <li>A & (B & C) == (A & B) & C == (A & B & C) * </ul> * * <p>For more info, visit: https://en.wikipedia.org/wiki/Associative_property#Propositional_logic */ export declare function applyAssociation(filter: Filter): Filter;