mingo

  • Version 6.4.15
  • Published
  • 863 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: 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

      Returns

      {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

      Returns

      {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

      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?: 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

        Returns

        {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

      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

          Returns

          {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

          Returns

          {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

          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>