mingo
Version:
MongoDB query language for in-memory objects
68 lines (67 loc) • 3.11 kB
TypeScript
import { Any, AnyObject, BsonType, JsType, Options } from "../types";
type ConversionType = number | Exclude<JsType, "function"> | BsonType;
/**
* Builds a predicate for $elemMatch operator to remove repeated work required for each element in the array.
* This includes pre-compiling the query and determining if we need to wrap non-objects in a temporary object.
*/
declare function elemMatchPredicate(criteria: AnyObject, options: Options): (v: Any) => boolean;
export type QueryPredicate = (_a: Any, _b: Any, _o: Options) => boolean;
export declare function processQuery(selector: string, value: Any, options: Options, predicate: QueryPredicate): (_: AnyObject) => boolean;
export declare function processExpression(obj: AnyObject, expr: Any, options: Options, predicate: QueryPredicate): boolean;
/**
* Checks that two values are equal.
*/
export declare function $eq(a: Any, b: Any, options?: Options): boolean;
/**
* Matches all values that are not equal to the value specified in the query.
*/
export declare function $ne(a: Any, b: Any, options?: Options): boolean;
/**
* Matches any of the values that exist in an array specified in the query.
*/
export declare function $in(a: Any[], b: Any[], _options?: Options): boolean;
/**
* Matches values that do not exist in an array specified to the query.
*/
export declare function $nin(a: Any[], b: Any[], options?: Options): boolean;
/**
* Matches values that are less than the value specified in the query.
*/
export declare function $lt(a: Any, b: Any, _options?: Options): boolean;
/**
* Matches values that are less than or equal to the value specified in the query.
*/
export declare function $lte(a: Any, b: Any, _options?: Options): boolean;
/**
* Matches values that are greater than the value specified in the query.
*/
export declare function $gt(a: Any, b: Any, _options?: Options): boolean;
/**
* Matches values that are greater than or equal to the value specified in the query.
*/
export declare function $gte(a: Any, b: Any, _options?: Options): boolean;
/**
* Performs a modulo operation on the value of a field and selects documents with a specified result.
*/
export declare function $mod(a: Any, b: number[], _options: Options): boolean;
/**
* Selects documents where values match a specified regular expression.
*/
export declare function $regex(a: Any, b: RegExp, options?: Options): boolean;
/**
* Matches arrays that contain all elements specified in the query.
*/
export declare function $all(values: Any[], rhs: AnyObject[], options: Options): boolean;
/**
* Selects documents if the array field is a specified size.
*/
export declare function $size(a: Any[], b: number, _options?: Options): boolean;
/**
* Selects documents if element in the array field matches all the specified $elemMatch condition.
*/
export declare function $elemMatch(a: Any[], b: ReturnType<typeof elemMatchPredicate>, _options: Options): boolean;
/**
* Selects documents if a field is of the specified type.
*/
export declare function $type(a: Any, b: ConversionType | ConversionType[], options?: Options): boolean;
export {};