UNPKG

mingo

Version:

MongoDB query language for in-memory objects

56 lines (55 loc) 2.97 kB
import { Aggregator as AggregatorBase } from "./aggregator"; import { Context, ProcessingMode } from "./core/_internal"; import { Cursor } from "./cursor"; import type { Source } from "./lazy"; import { Query as QueryBase } from "./query"; import type { AnyObject, Criteria, Options, Projection } from "./types"; import * as updater from "./updater"; export { Context, ProcessingMode } from "./core"; export declare class Query<T = AnyObject> extends QueryBase<T> { constructor(condition: Criteria<T>, options?: Partial<Options>); } export declare class Aggregator extends AggregatorBase { constructor(pipeline: AnyObject[], options?: Partial<Options>); } /** * Finds documents in a collection that match the specified criteria. * * @template R - The type of the documents in the collection. * @param collection - The source collection to search. * @param condition - The query criteria to filter the documents. * @param projection - Optional. Specifies the fields to include or exclude in the returned documents. * @param options - Optional. Additional options to customize the query behavior. * @returns A `Cursor` object that allows iteration over the matching documents. */ export declare function find<R = AnyObject, T = AnyObject>(collection: Source, condition: Criteria<T>, projection?: Projection<R>, options?: Partial<Options>): Cursor<R>; /** * Performs an aggregation operation on the provided collection using the specified pipeline. * * @param collection - The input data source to aggregate. * @param pipeline - An array of aggregation stages to process the collection. * @param options - Optional settings to customize the aggregation behavior. * @returns The result of the aggregation as an array of objects. */ export declare function aggregate(collection: Source, pipeline: AnyObject[], options?: Partial<Options>): AnyObject[]; export declare function update<T extends AnyObject>(obj: T, modifier: updater.Modifier<T>, arrayFilters?: AnyObject[], condition?: Criteria<T>, options?: { cloneMode?: updater.CloneMode; queryOptions?: Partial<Options>; }): string[]; export declare function updateMany<T extends AnyObject>(documents: T[], condition: Criteria<T>, modifer: updater.Modifier<T> | updater.PipelineStage[], updateConfig?: updater.UpdateConfig, options?: Partial<Options>): { matchedCount: number; modifiedCount: number; }; export declare function updateOne<T extends AnyObject>(documents: T[], condition: Criteria<T>, modifier: updater.Modifier<T> | updater.PipelineStage[], updateConfig?: updater.UpdateConfig, options?: Partial<Options>): updater.UpdateResult; declare const _default: { Aggregator: typeof Aggregator; Context: typeof Context; ProcessingMode: typeof ProcessingMode; Query: typeof Query; aggregate: typeof aggregate; find: typeof find; update: typeof update; updateMany: typeof updateMany; updateOne: typeof updateOne; }; export default _default;