mingo

  • Version 7.0.2
  • Published
  • 1.06 MB
  • No dependencies
  • MIT license

Install

npm i mingo
yarn add mingo
pnpm add mingo

Overview

MongoDB query language for in-memory objects

Index

Variables

variable _default

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;
};

    Functions

    function aggregate

    aggregate: (
    collection: Source,
    pipeline: AnyObject[],
    options?: Partial<Options>
    ) => AnyObject[];
    • Performs an aggregation operation on the provided collection using the specified pipeline.

      Parameter collection

      The input data source to aggregate.

      Parameter pipeline

      An array of aggregation stages to process the collection.

      Parameter options

      Optional settings to customize the aggregation behavior.

      Returns

      The result of the aggregation as an array of objects.

    function find

    find: <T>(
    collection: Source,
    condition: AnyObject,
    projection?: AnyObject,
    options?: Partial<Options>
    ) => Cursor<T>;
    • Finds documents in a collection that match the specified criteria.

      T - The type of the documents in the collection.

      Parameter collection

      The source collection to search.

      Parameter condition

      The query criteria to filter the documents.

      Parameter projection

      Optional. Specifies the fields to include or exclude in the returned documents.

      Parameter options

      Optional. Additional options to customize the query behavior.

      Returns

      A Cursor object that allows iteration over the matching documents.

    function update

    update: (
    obj: AnyObject,
    modifier: updater.Modifier,
    arrayFilters?: AnyObject[],
    condition?: AnyObject,
    options?: { cloneMode?: updater.CloneMode; queryOptions?: Partial<Options> }
    ) => string[];

      function updateMany

      updateMany: (
      documents: AnyObject[],
      condition: AnyObject,
      modifer: updater.Modifier | updater.PipelineStage[],
      updateConfig?: updater.UpdateConfig,
      options?: Partial<Options>
      ) => { matchedCount: number; modifiedCount: number };

        function updateOne

        updateOne: (
        documents: AnyObject[],
        condition: AnyObject,
        modifier: updater.Modifier | updater.PipelineStage[],
        updateConfig?: updater.UpdateConfig,
        options?: Partial<Options>
        ) => updater.UpdateResult;

          Classes

          class Aggregator

          class Aggregator extends AggregatorBase {}

            constructor

            constructor(pipeline: AnyObject[], options?: Partial<Options>);

              class Context

              class Context {}
              • The Context class is a utility for managing and organizing operators of various types. It provides methods to initialize, merge, and retrieve operators, as well as add specific types of operators to the context.

              method addAccumulatorOps

              addAccumulatorOps: (ops: AccumulatorOps) => Context;

                method addExpressionOps

                addExpressionOps: (ops: ExpressionOps) => Context;

                  method addPipelineOps

                  addPipelineOps: (ops: PipelineOps) => Context;

                    method addProjectionOps

                    addProjectionOps: (ops: ProjectionOps) => Context;

                      method addQueryOps

                      addQueryOps: (ops: QueryOps) => Context;

                        method addWindowOps

                        addWindowOps: (ops: WindowOps) => Context;

                          method from

                          static from: (ctx?: Context) => Context;

                            method getOperator

                            getOperator: (type: OpType, name: string) => Operator | null;

                              method init

                              static init: (ops?: {
                              accumulator?: AccumulatorOps;
                              expression?: ExpressionOps;
                              pipeline?: PipelineOps;
                              projection?: ProjectionOps;
                              query?: QueryOps;
                              window?: WindowOps;
                              }) => Context;

                                method merge

                                static merge: (first: Context, second: Context) => Context;

                                  class Query

                                  class Query extends QueryBase {}

                                    constructor

                                    constructor(condition: AnyObject, options?: Partial<Options>);

                                      Enums

                                      enum ProcessingMode

                                      enum ProcessingMode {
                                      CLONE_OFF = 0,
                                      CLONE_INPUT = 1,
                                      CLONE_OUTPUT = 2,
                                      CLONE_ALL = 3,
                                      }
                                      • Enum representing the processing modes for handling input and output documents. This determines whether cloning is applied to maintain immutability or ensure distinct object references.

                                      member CLONE_ALL

                                      CLONE_ALL = 3
                                      • Clone both input and output documents. Combines CLONE_INPUT and CLONE_OUTPUT.

                                      member CLONE_INPUT

                                      CLONE_INPUT = 1
                                      • Clone input documents to maintain immutability of the original input.

                                      member CLONE_OFF

                                      CLONE_OFF = 0
                                      • Do not clone inputs or outputs. Resulting documents may share references. This is the default mode.

                                      member CLONE_OUTPUT

                                      CLONE_OUTPUT = 2
                                      • Clone output documents to ensure distinct objects without shared references.

                                      Package Files (2)

                                      Dependencies (0)

                                      No dependencies.

                                      Dev Dependencies (0)

                                      No dev dependencies.

                                      Peer Dependencies (0)

                                      No peer dependencies.

                                      Badge

                                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/mingo.

                                      • Markdown
                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/mingo)
                                      • HTML
                                        <a href="https://www.jsdocs.io/package/mingo"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>