• Version 5.0.0
  • Published
  • 411 kB
  • No dependencies
  • MIT license


npm i mingo
yarn add mingo
pnpm add mingo


MongoDB query language for in-memory objects



variable _default

const _default: {
Aggregator: typeof Aggregator;
Query: typeof Query;
aggregate: typeof aggregate;
find: typeof find;
remove: typeof remove;


    function aggregate

    aggregate: (
    collection: Source,
    pipeline: Array<RawObject>,
    options?: Options
    ) => RawArray;
    • Return the result collection after running the aggregation pipeline for the given collection. Shorthand for (new Aggregator(pipeline, options)).run(collection)

      Parameter collection

      Collection or stream of objects

      Parameter pipeline

      The pipeline operators to use

      Parameter options


      {Array} New array of results

    function find

    find: (
    collection: Source,
    criteria: RawObject,
    projection?: RawObject,
    options?: Options
    ) => Cursor;
    • Performs a query on a collection and returns a cursor object. Shorthand for Query(criteria).find(collection, projection)

      Parameter collection

      Array of objects

      Parameter criteria

      Query criteria

      Parameter projection

      Projection criteria

      Parameter options


      {Cursor} A cursor of results

    function remove

    remove: (
    collection: Collection,
    criteria: RawObject,
    options?: Options
    ) => RawObject[];
    • Returns a new array without objects which match the criteria

      Parameter collection

      Array of objects

      Parameter criteria

      Query criteria of objects to remove

      Parameter options


      {Array} New filtered array


    class Aggregator

    class Aggregator {}
    • Provides functionality for the mongoDB aggregation pipeline

      Parameter pipeline

      an Array of pipeline operators

      Parameter options

      An optional Options to pass the aggregator


    constructor(pipeline: RawObject[], options?: Options);

      property options

      readonly options?: Options;

        property pipeline

        readonly pipeline: RawObject[];

          method run

          run: (collection: Source) => Collection;
          • Return the results of the aggregation as an array.

            Parameter collection

            Parameter query

          method stream

          stream: (collection: Source) => Iterator;
          • Returns an Lazy iterator for processing results of pipeline

            Parameter collection

            An array or iterator object

            Parameter query

            the Query object to use as context


            {Iterator} an iterator object

          class Query

          class Query {}
          • An object used to filter input documents

            Parameter criteria

            The criteria for constructing predicates

            Parameter options

            Options for use by operators


          constructor(criteria: RawObject, options?: Options);

            method find

            find: (collection: Source, projection?: RawObject) => Cursor;
            • Returns a cursor to select matching documents from the input source.

              Parameter source

              A source providing a sequence of documents

              Parameter projection

              An optional projection criteria


              {Cursor} A Cursor for iterating over the results

            method remove

            remove: (collection: Collection) => Collection;
            • Remove matched documents from the collection returning the remainder

              Parameter collection

              An array of documents


              {Array} A new array with matching elements removed

            method test

            test: (obj: RawObject) => boolean;
            • Checks if the object passes the query criteria. Returns true if so, false otherwise.

              Parameter obj

              The object to test


              {boolean} True or false

            Package Files (3)

            Dependencies (0)

            No dependencies.

            Dev Dependencies (0)

            No dev dependencies.

            Peer Dependencies (0)

            No peer dependencies.


            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
            • HTML
              <a href="https://www.jsdocs.io/package/mingo"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>