UNPKG

mingo

Version:

MongoDB query language for in-memory objects

56 lines (55 loc) 2.84 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, Options } from "./types"; import * as updater from "./updater"; export { Context, ProcessingMode } from "./core"; export declare class Query extends QueryBase { constructor(condition: AnyObject, 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 T - 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<T>(collection: Source, condition: AnyObject, projection?: AnyObject, options?: Partial<Options>): Cursor<T>; /** * 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(obj: AnyObject, modifier: updater.Modifier, arrayFilters?: AnyObject[], condition?: AnyObject, options?: { cloneMode?: updater.CloneMode; queryOptions?: Partial<Options>; }): string[]; export declare function updateMany(documents: AnyObject[], condition: AnyObject, modifer: updater.Modifier | updater.PipelineStage[], updateConfig?: updater.UpdateConfig, options?: Partial<Options>): { matchedCount: number; modifiedCount: number; }; export declare function updateOne(documents: AnyObject[], condition: AnyObject, modifier: updater.Modifier | 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;