mingo
    Preparing search index...

    Class Query

    Represents a query object used to filter and match documents based on specified criteria.

    The Query class provides methods to compile query conditions, test objects against the query criteria, and retrieve matching documents from a collection.

    const query = new Query({ age: { $gt: 18 } });
    const result = query.test({ name: "John", age: 25 }); // true

    The type of objects being queried.

    Index

    Constructors

    Methods

    Constructors

    • Creates an instance of the query with the specified condition and options.

      Parameters

      • condition: AnyObject

        The query condition object used to define the criteria for matching documents.

      • Optionaloptions: Partial<Options>

        Optional configuration settings to customize the query behavior.

      Returns Query

    Methods

    • Returns a cursor for iterating over the items in the given collection that match the query criteria.

      Type Parameters

      • T

        The type of the items in the resulting cursor.

      Parameters

      • collection: Source

        The source collection to search through.

      • Optionalprojection: AnyObject

        An optional object specifying fields to include or exclude in the returned items.

      Returns Cursor<T>

      A Cursor instance for iterating over the matching items.

    • Tests whether the given object satisfies all compiled predicates.

      Type Parameters

      • T

        The type of the object to test.

      Parameters

      • obj: T

        The object to be tested against the compiled predicates.

      Returns boolean

      true if the object satisfies all predicates, otherwise false.