MongoDB: cursor.min() method

Last update on April 14 2018 06:14:57 (UTC/GMT +8 hours)

cursor.min

The cursor.min() method is used to specify an inclusive lower bound for a specific index in order to constrain the results of find(). This method provides a way to specify lower bounds on compound key indexes.

Syntax:

cursor.min()

Parameters:

Name

Description

Required /
Optional

Type

indexBounds

The inclusive lower bound for the index keys.

Required

document

The indexBounds parameter has the following prototype form:

{ field1: <min value>, field2: <min value2> ... fieldN:<min valueN> }

The fields correspond to all the keys of a particular index in order. You can explicitly specify the particular index with the hint() method. Otherwise, MongoDB selects the index using the fields in the indexBounds; however, if multiple indexes exist on same fields with different sort orders, the selection of the index may be ambiguous.

min() exists primarily to support the mongos process, and is a shell wrapper around the query modifier $min.