diff --git a/source/administration/indexes.txt b/source/administration/indexes.txt index 68298e0ac70..f6b86229c26 100644 --- a/source/administration/indexes.txt +++ b/source/administration/indexes.txt @@ -44,7 +44,7 @@ all documents in a collection for documents that match the query. db.records.find( { user_id: 2 } ) However, the following query, on the ``profile_url`` field is not - supported by this index:: + supported by this index: .. code-block:: javascript diff --git a/source/core/read-operations.txt b/source/core/read-operations.txt index 6353c5c7c4a..0461aab0233 100644 --- a/source/core/read-operations.txt +++ b/source/core/read-operations.txt @@ -34,7 +34,7 @@ In the :program:`mongo` shell, the :method:`find() ` and :method:`findOne() ` methods perform read operations. The :method:`find() ` method has the following -syntax: +syntax [#formal-query-structure]_: .. code-block:: javascript @@ -69,7 +69,7 @@ syntax: necessarily consistent unless you specify a sort (:method:`sort() `). -For example, the following operation on the ``inventory`` collection, +For example, the following operation on the ``inventory`` collection selects all documents where the ``type`` field equals ``'food'`` and the ``price`` field has a value less than ``9.95``. The projection limits the response to the ``item`` and ``qty``, and ``_id`` field: @@ -93,6 +93,20 @@ For additional documentation and examples of the main MongoDB read operators, refer to the :doc:`/applications/read` page of the :doc:`/crud` section. +.. [#formal-query-structure] + :method:`db.collection.find( \, \ ) + ` is a wrapper for the more formal query + structure with the :operator:`$query` operator: + + .. code-block:: javascript + + db.collection.find( { $query: , ... }, ) + + Within the formal structure, in addition to the :operator:`$query` + operator, you can use the :doc:`meta query operators + ` to modify the behavior of the + query. + .. _read-operations-query-document: .. _read-operations-query-argument: @@ -411,7 +425,7 @@ the query used an index. This query: - returned 5 documents, as indicated by the :data:`n` field; - scanned 5 documents from the index, as indicated by the - :data:`nscanned`` field; + :data:`nscanned` field; - then read 5 full documents from the collection, as indicated by the :data:`nscannedObjects` field. diff --git a/source/reference/meta-query-operators.txt b/source/reference/meta-query-operators.txt index edbe2a6e2a9..9e1b5cecfe7 100644 --- a/source/reference/meta-query-operators.txt +++ b/source/reference/meta-query-operators.txt @@ -11,25 +11,25 @@ Introduction In addition to the :doc:`MongoDB Query Operators `, there are a number of "meta" operators that -you may use to modify the output or behavior of a -query. Specify these modifiers to a :method:`db.collection.find()` query, in the -following form (for the :program:`mongo` shell): +you may use to modify the output or behavior of a query. On the server, +MongoDB treats the query and the options as a single object. The +:program:`mongo` shell may provide :ref:`cursor methods +` for these options. When possible, use these +methods; otherwise, you can add these options using either of the +following syntax: .. code-block:: javascript - db.collection.find( { [QUERY] } )._addSpecial( [MODIFIER] ) - -Here, the query specified by ``[QUERY]`` runs on the collection -named ``collection`` with the operation specified by the -``[MODIFIER]``. The results are then processed by a modifier expression -selected from the following list. Many of the operators have -corresponding :doc:`methods in the shell `. For -the proposes of this reference, this document assumes the above form -where possible. + db.collection.find( { } )._addSpecial(