@@ -21,19 +21,19 @@ cursor.min()
21
21
22
22
.. code-block:: javascript
23
23
24
- { field1: <min value>, field2: <min value2> ... fieldN:<min valueN>}
24
+ { field1: <min value>, field2: <min value2> ... fieldN:<min valueN>}
25
25
26
26
The fields correspond to *all* the keys of a particular index
27
27
*in order*. You can explicitly specify the particular index
28
28
with the :method:`hint() <cursor.hint()>` method. Otherwise,
29
- :program:`mongod` selects the index using the fields in the
29
+ MongoDB selects the index using the fields in the
30
30
``indexbounds``; however, if multiple indexes exist on same
31
31
fields with different sort orders, the selection of the index
32
32
may be ambiguous.
33
33
34
- Consider the following examples of :method:`min() <cursor.min()>`:
35
-
36
- The examples assume a collection ``products`` with the following documents:
34
+ Consider the following example of :method:`min() <cursor.min()>`,
35
+ which assumes a collection named ``products`` that holds the
36
+ following documents:
37
37
38
38
.. code-block:: javascript
39
39
@@ -47,8 +47,8 @@ cursor.min()
47
47
{ "_id" : 10, "item" : "orange", "type" : "navel", "price" : 1.39 }
48
48
{ "_id" : 9, "item" : "orange", "type" : "satsuma", "price" : 1.99 }
49
49
{ "_id" : 8, "item" : "orange", "type" : "valencia", "price" : 0.99 }
50
-
51
- The collection has the following four indexes:
50
+
51
+ The collection has the following indexes:
52
52
53
53
.. code-block:: javascript
54
54
@@ -60,13 +60,12 @@ cursor.min()
60
60
- Using the ordering of ``{ item: 1, type: 1 }`` index,
61
61
:method:`min() <cursor.min()>` limits the query to the documents
62
62
that are at or above the index key bound of ``item`` equal to
63
- ``apple`` and ``type`` equal to ``jonagold``:
64
-
63
+ ``apple`` and ``type`` equal to ``jonagold``, as in the following :
64
+
65
65
.. code-block:: javascript
66
66
67
67
db.products.find().min( { item: 'apple', type: 'jonagold' } ).hint( { item: 1, type: 1 } )
68
68
69
-
70
69
The query returns the following documents:
71
70
72
71
.. code-block:: javascript
@@ -106,15 +105,15 @@ cursor.min()
106
105
107
106
.. note::
108
107
109
- - Because :method:`min() <cursor.min()>` requires a corresponding
110
- index as well as enforces the use of that index, it may be
111
- preferable to use the :operator:`$gte` operator in the query if
108
+ - Because :method:`min() <cursor.min()>` requires an index on a
109
+ field, and forces the query to use this index, you may prefer
110
+ the :operator:`$gte` operator for the query if
112
111
possible. Consider the following example:
113
-
112
+
114
113
.. code-block:: javascript
115
-
116
- db.products.find( { _id: 7 } ).min( { price: 1.39 } )
117
-
114
+
115
+ db.products.find( { _id: 7 } ).min( { price: 1.39 } )
116
+
118
117
The query will use the index on the ``price`` field, even if
119
118
the index on ``_id`` may be better.
120
119
0 commit comments