@@ -43,7 +43,7 @@ Sample Data
4343The examples in this guide use the ``Band`` model, which represents a
4444band or musical group. The definition of the ``Band`` model might be
4545different for each section to demonstrate different query
46- functionalities. Some sections might also use other supplementary models
46+ functionalities. Some sections might use other models
4747to demonstrate query functionality.
4848
4949Queries in {+odm+}
@@ -492,9 +492,9 @@ an array field with at least one element that matches all the specified
492492query criteria.
493493
494494The following example creates a sample document that contains an array
495- field, then uses the ``elem_match()`` method to match documents in
496- which the ``tour`` array field contains an entry in which the value of
497- the ``city`` field is ``'London'``:
495+ field. Then, it uses the ``elem_match()`` method to match documents in
496+ which the ``tour`` array field contains an entry in which the ``city``
497+ value is ``'London'``:
498498
499499.. literalinclude:: /includes/interact-data/query.rb
500500 :start-after: start-elem-match-1
@@ -529,7 +529,7 @@ field:
529529.. note::
530530
531531 You cannot use ``elem_match()`` on non-embedded associations because
532- MongoDB does not perform a join on the collections.
532+ MongoDB does not perform a join operation on the collections.
533533 If you perform this query, the conditions are added to the collection
534534 that is the source of the non-embedded association rather than the
535535 collection of the association.
@@ -546,7 +546,7 @@ as shown in the following example:
546546Querying by _id Value
547547---------------------
548548
549- {+odm+} provides the ``find()`` method that allows you to query
549+ {+odm+} provides the ``find()`` method, which allows you to query
550550documents by their ``_id`` values.
551551
552552The following example uses the ``find()`` method to match a document
@@ -558,8 +558,8 @@ with the specified ``_id`` field value:
558558
559559.. note:: Type Conversion
560560
561- The ``find()`` method performs the type conversion of the argument that
562- you pass to the type declared for the ``_id`` field in the model. By
561+ The ``find()`` method converts the ID that you pass to the
562+ data type declared for the ``_id`` field in the model. By
563563 default, the ``_id`` field is defined as a ``BSON::ObjectId`` type.
564564
565565 The preceding example is equivalent to the following code, which
@@ -596,13 +596,13 @@ The ``find()`` method exhibits the following behavior:
596596 depends on the value of the ``raise_not_found_error`` configuration
597597 option.
598598
599- If you set the option to ``true``, ``find()`` raises a
600- ``Mongoid::Errors::DocumentNotFound`` error if any of the ``_id``
601- values are not found.
599+ If you set the ``raise_not_found_error`` option to ``true``,
600+ ``find()`` raises a `` Mongoid::Errors::DocumentNotFound`` error if any
601+ of the ``_id`` values are not found.
602602
603- If you set the option to ``false`` and query for a single ``_id``
604- value, ``find()`` returns ``nil`` if {+odm+} does not match any
605- document. If you pass multiple ``_id`` values and
603+ If you set the ``raise_not_found_error`` option to ``false`` and query
604+ for a single ``_id`` value, ``find()`` returns ``nil`` if {+odm+} does
605+ not match a document. If you pass multiple ``_id`` values and
606606 some or all are not matched, the return value is an array of any documents
607607 that match, or an empty array if no documents match.
608608
@@ -627,7 +627,7 @@ The following code demonstrates how to use the ``find_by()`` method:
627627
628628You can use the ``find_or_create_by()`` method to retrieve documents
629629based on the provided criteria. If no documents are found, it creates
630- and returns a newly persisted one .
630+ and returns an instance that is saved to MongoDB .
631631
632632The following code demonstrates how to use the ``find_or_create_by()``
633633method:
@@ -638,10 +638,11 @@ method:
638638 :language: ruby
639639 :dedent:
640640
641- You can use the ``find_or_initialize_by()`` method to to retrieve documents
641+ You can use the ``find_or_initialize_by()`` method to retrieve documents
642642based on the provided criteria. If no documents are found, it returns a
643- new one, without persisting it. The syntax for
644- ``find_or_initialize_by()`` is the same as in the preceding example.
643+ new one, without persisting it to MongoDB. The syntax for
644+ ``find_or_initialize_by()`` is the same for the ``find_or_create_by()``
645+ method.
645646
646647Regular Expressions
647648-------------------
@@ -664,8 +665,8 @@ shown in the following code:
664665 Band.where(name: /impala/i)
665666 # => Returns sample document
666667
667- You can also perform queries by using PCRE syntax and
668- ``BSON::Regexp::Raw`` objects:
668+ You can also perform queries by using Perl Compatible Regular Expression
669+ (PCRE) syntax and ``BSON::Regexp::Raw`` objects:
669670
670671.. literalinclude:: /includes/interact-data/query.rb
671672 :start-after: start-regex
@@ -676,12 +677,12 @@ You can also perform queries by using PCRE syntax and
676677Field Type Query Conversions
677678----------------------------
678679
679- When you specify a query on a field defined in a model, {+odm+} converts
680- the query value based on how the field is defined, and if it has a
681- specified type .
680+ When you specify a query on a field defined in a model, if the field has
681+ a *specified data type*, {+odm+} converts the query value based on how the
682+ field is defined .
682683
683684Consider the following ``Album`` model definition that
684- contains a ``Date``-valued field, a ``Time``-valued field and an
685+ contains a ``Date``-valued field, a ``Time``-valued field, and an
685686implicit ``Object``-valued field. The model also intentionally *does not define*
686687a field named ``last_reviewed``:
687688
@@ -718,7 +719,7 @@ In the preceding example, the following conversions apply:
718719 ``last_commented`` field, {+odm+} interprets the date to be in local
719720 time and applies the :ref:`configured time zone <>`.
720721
721- - When querying on the ``last_purchased`` field that has no explicit
722+ - When querying on the ``last_purchased`` field, which has no explicit
722723 type, the date is used unmodified in the constructed query.
723724
724725- When querying on the undefined ``last_reviewed`` field, {+odm+}
@@ -792,9 +793,6 @@ result from the list of returned documents based on its position.
792793- ``second()``: Returns the second matching document. Automatically uses
793794 a sort on the ``_id`` field.
794795
795- - ``second()``: Returns the second matching document. Automatically uses
796- a sort on the ``_id`` field.
797-
798796- ``third()``: Returns the third matching document. Automatically uses
799797 a sort on the ``_id`` field.
800798
@@ -804,11 +802,11 @@ result from the list of returned documents based on its position.
804802- ``fifth()``: Returns the fifth matching document. Automatically uses
805803 a sort on the ``_id`` field.
806804
807- - ``second_to_last()``: Returns the second to last matching document.
808- Automatically usesa sort on the ``_id`` field. *See line 14 in the
805+ - ``second_to_last()``: Returns the second-to- last matching document.
806+ Automatically uses a sort on the ``_id`` field. *See line 14 in the
809807 following code for an example.*
810808
811- - ``third_to_last()``: Returns the third to last matching document.
809+ - ``third_to_last()``: Returns the third-to- last matching document.
812810 Automatically uses a sort on the ``_id`` field.
813811
814812The following code demonstrates how to use some methods described
@@ -823,11 +821,11 @@ in the preceding list:
823821
824822.. tip:: Error Generation
825823
826- Each method described in this section has a ``-!`` suffixed counterpart
827- that returns an error if {+odm+} doesn't match any documents. For
828- example, to implement error handling in your application when your
829- query returns no results, use the ``first!()`` method instead of
830- ``first()``.
824+ Each method described in this section has a variation that is
825+ suffixed with ``!`` that returns an error if {+odm+} doesn't match
826+ any documents. For example, to implement error handling in your
827+ application when your query returns no results, use the ``first!()``
828+ method instead of ``first()``.
831829
832830Survey Field Values
833831~~~~~~~~~~~~~~~~~~~
@@ -900,8 +898,8 @@ category:
900898Additional Information
901899----------------------
902900
903- To learn how to modify how {+odm+} returns results to you, see
901+ To learn how to modify the way that {+odm+} returns results to you, see
904902:ref:`mongoid-data-modify-results`.
905903
906904To learn more about defining scopes on your models, see
907- :ref:`mongoid-data-scoping`.
905+ :ref:`mongoid-data-scoping`.
0 commit comments