mingo

  • Version 5.0.0
  • Published
  • 411 kB
  • 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;
Query: typeof Query;
aggregate: typeof aggregate;
find: typeof find;
remove: typeof remove;
};

    Functions

    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

      Returns

      {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

      Returns

      {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

      Returns

      {Array} New filtered array

    Classes

    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

    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

            Returns

            {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

          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

              Returns

              {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

              Returns

              {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

              Returns

              {boolean} True or false

            Package Files (3)

            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>