• Version 6.4.15
  • Published
  • 863 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: RawObject[],
    options?: Partial<Options>
    ) => RawObject[];
    • Return the result collection after running the aggregation pipeline for the given collection. Shorthand for (new Aggregator(pipeline, options)).run(collection)

      Parameter collection

      array or stream of objects

      Parameter pipeline

      The pipeline operators to use

      Parameter options


      {Array} New array of results

    function find

    find: <T>(
    collection: Source,
    criteria: RawObject,
    projection?: RawObject,
    options?: Partial<Options>
    ) => Cursor<T>;
    • 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: RawObject[],
    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?: Partial<Options>);

      method run

      run: <T extends RawObject>(collection: Source) => T[];
      • 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


        {Iterator} an iterator object

      class Query

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

        Parameter condition

        The condition for constructing predicates

        Parameter options

        Options for use by operators


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

        method find

        find: <T>(collection: Source, projection?: RawObject) => Cursor<T>;
        • 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: <T>(collection: T[]) => T[];
        • 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: <T>(obj: T) => 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>