diff --git a/.github/workflows/copy-compat-to-docs-shared.yml b/.github/workflows/copy-compat-to-docs-shared.yml new file mode 100644 index 00000000..f04fa143 --- /dev/null +++ b/.github/workflows/copy-compat-to-docs-shared.yml @@ -0,0 +1,80 @@ +name: Copy Files to docs-shared + +on: + workflow_dispatch: {} # use to manually trigger workflow + push: + branches: + - "master" + paths: + - "source/includes/mongodb-compatibility-table-mongoid.rst" + - "source/includes/language-compatibility-table-mongoid.rst" + - "source/includes/rails-compatibility-table-mongoid.rst" + - "source/includes/ror-compatibility-table-mongoid.rst" + - "source/includes/ruby-driver-compatibility-table-mongoid.rst" + +jobs: + copy-file: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Copy mongodb-compat table + uses: dmnemec/copy_file_to_another_repo_action@main + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + with: + source_file: "source/includes/mongodb-compatibility-table-mongoid.rst" + destination_repo: "10gen/docs-shared" + destination_folder: "dbx" + user_email: "docs-builder-bot@mongodb.com" + user_name: "docs-builder-bot" + commit_message: "Auto-import from docs-mongoid" + + - name: Copy language-compat table + uses: dmnemec/copy_file_to_another_repo_action@main + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + with: + source_file: "source/includes/language-compatibility-table-mongoid.rst" + destination_repo: "10gen/docs-shared" + destination_folder: "dbx" + user_email: "docs-builder-bot@mongodb.com" + user_name: "docs-builder-bot" + commit_message: "Auto-import from docs-mongoid" + + - name: Copy ruby-on-rails-compat table + uses: dmnemec/copy_file_to_another_repo_action@main + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + with: + source_file: "source/includes/rails-compatibility-table-mongoid.rst" + destination_repo: "10gen/docs-shared" + destination_folder: "dbx" + user_email: "docs-builder-bot@mongodb.com" + user_name: "docs-builder-bot" + commit_message: "Auto-import from docs-mongoid" + + - name: Copy rails-feature-compat table + uses: dmnemec/copy_file_to_another_repo_action@main + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + with: + source_file: "source/includes/ror-compatibility-table-mongoid.rst" + destination_repo: "10gen/docs-shared" + destination_folder: "dbx" + user_email: "docs-builder-bot@mongodb.com" + user_name: "docs-builder-bot" + commit_message: "Auto-import from docs-mongoid" + + - name: Copy ruby-driver-compat table + uses: dmnemec/copy_file_to_another_repo_action@main + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + with: + source_file: "source/includes/ruby-driver-compatibility-table-mongoid.rst" + destination_repo: "10gen/docs-shared" + destination_folder: "dbx" + user_email: "docs-builder-bot@mongodb.com" + user_name: "docs-builder-bot" + commit_message: "Auto-import from docs-mongoid" diff --git a/config/redirects b/config/redirects index 2516d155..a0b5418b 100644 --- a/config/redirects +++ b/config/redirects @@ -1,10 +1,72 @@ define: prefix docs/mongoid -define: base https://www.mongodb.com/docs/mongoid -define: versions 8.1 upcoming +define: base https://www.mongodb.com/${prefix} +define: versions v9.0 master -symlink: current -> 8.1 +symlink: current -> v9.0 +symlink: upcoming -> master raw: ${prefix}/ -> ${base}/current/ -raw: ${prefix}/master -> ${base}/upcoming/ +raw: ${prefix}/stable -> ${base}/current/ -raw: ${prefix}/current/release-notes/mongoid-7.0 -> ${base}/current/ +# Redirects for standardized (new) page URLs in old docs +[*-v9.0]: ${prefix}/${version}/compatibility/ -> ${base}/${version}/reference/compatibility/ +[*-v9.0]: ${prefix}/${version}/configuration/ -> ${base}/${version}/reference/configuration/ +[*-v9.0]: ${prefix}/${version}/integrations-tools/rails-integration/ -> ${base}/${version}/reference/rails-integration/ +[*-v9.0]: ${prefix}/${version}/quick-start-sinatra/ -> ${base}/${version}/tutorials/getting-started-sinatra/ +[*-v9.0]: ${prefix}/${version}/quick-start-rails/ -> ${base}/${version}/tutorials/getting-started-rails7/ +[*-v9.0]: ${prefix}/${version}/data-modeling/documents/ -> ${base}/${version}/tutorials/documents/ +[*-v9.0]: ${prefix}/${version}/security/encryption/ -> ${base}/${version}/tutorials/automatic-encryption/ +[*-v9.0]: ${prefix}/${version}/data-modeling/field-types/ -> ${base}/${version}/reference/fields/ +[*-v9.0]: ${prefix}/${version}/data-modeling/inheritance/ -> ${base}/${version}/reference/inheritance/ +[*-v9.0]: ${prefix}/${version}/data-modeling/associations/ -> ${base}/${version}/reference/associations/ +[*-v9.0]: ${prefix}/${version}/data-modeling/validation/ -> ${base}/${version}/reference/validation/ +[*-v9.0]: ${prefix}/${version}/configuration/collection-config/ -> ${base}/${version}/reference/collection-configuration/ +[*-v9.0]: ${prefix}/${version}/data-modeling/indexes/ -> ${base}/${version}/reference/indexes/ +[*-v9.0]: ${prefix}/${version}/configuration/sharding/ -> ${base}/${version}/reference/sharding/ +[*-v9.0]: ${prefix}/${version}/interact-data/crud/ -> ${base}/${version}/reference/crud/ +[*-v9.0]: ${prefix}/${version}/interact-data/specify-query/ -> ${base}/${version}/reference/queries/ +[*-v9.0]: ${prefix}/${version}/interact-data/text-search/ -> ${base}/${version}/reference/text-search/ +[*-v9.0]: ${prefix}/${version}/interact-data/aggregation/ -> ${base}/${version}/reference/aggregation/ +[*-v9.0]: ${prefix}/${version}/configuration/persistence-config/ -> ${base}/${version}/reference/persistence-configuration/ +[*-v9.0]: ${prefix}/${version}/interact-data/nested-attributes/ -> ${base}/${version}/reference/nested-attributes/ +[*-v9.0]: ${prefix}/${version}/data-modeling/callbacks/ -> ${base}/${version}/reference/callbacks/ +[*-v9.0]: ${prefix}/${version}/interact-data/transaction/ -> ${base}/${version}/reference/transactions/ +[*-v9.0]: ${prefix}/${version}/whats-new/ -> ${base}/${version}/release-notes/mongoid-9.0/ +[*-v9.0]: ${prefix}/${version}/code-documentation/ -> ${base}/${version}/contributing/code-documentation/ +[*-v9.0]: ${prefix}/${version}/issues-and-help/ -> ${base}/${version}/contributing/contributing-guidelines/ +[*-v9.0]: ${prefix}/${version}/integrations-tools/external-resources/ -> ${base}/${version}/ecosystem/ + +# Redirects for old page URLs in standardized (new) docs +[master]: ${prefix}/${version}/installation/ -> ${base}/${version}/#quick-start +[master]: ${prefix}/${version}/reference/compatibility/ -> ${base}/${version}/compatibility/ +[master]: ${prefix}/${version}/reference/configuration/ -> ${base}/${version}/configuration/ +[master]: ${prefix}/${version}/reference/rails-integration/ -> ${base}/${version}/integrations-tools/rails-integration/ +[master]: ${prefix}/${version}/tutorials/getting-started-sinatra/ -> ${base}/${version}/quick-start-sinatra/ +[master]: ${prefix}/${version}/tutorials/getting-started-rails7/ -> ${base}/${version}/quick-start-rails/ +[master]: ${prefix}/${version}/tutorials/getting-started-rails6/ -> ${base}/${version}/quick-start-rails/ +[master]: ${prefix}/${version}/tutorials/documents/ -> ${base}/${version}/data-modeling/documents/ +[master]: ${prefix}/${version}/tutorials/common-errors/ -> ${base}/${version}/ +[master]: ${prefix}/${version}/tutorials/automatic-encryption/ -> ${base}/${version}/security/encryption/ +[master]: ${prefix}/${version}/reference/fields/ -> ${base}/${version}/data-modeling/field-types/ +[master]: ${prefix}/${version}/reference/inheritance/ -> ${base}/${version}/data-modeling/inheritance/ +[master]: ${prefix}/${version}/reference/associations/ -> ${base}/${version}/data-modeling/associations/ +[master]: ${prefix}/${version}/reference/validation/ -> ${base}/${version}/data-modeling/validation/ +[master]: ${prefix}/${version}/reference/collection-configuration/ -> ${base}/${version}/configuration/collection-config/ +[master]: ${prefix}/${version}/reference/indexes/ -> ${base}/${version}/data-modeling/indexes/ +[master]: ${prefix}/${version}/reference/sharding/ -> ${base}/${version}/configuration/sharding/ +[master]: ${prefix}/${version}/reference/crud/ -> ${base}/${version}/interact-data/crud/ +[master]: ${prefix}/${version}/reference/queries/ -> ${base}/${version}/interact-data/specify-query/ +[master]: ${prefix}/${version}/reference/text-search/ -> ${base}/${version}/interact-data/text-search/ +[master]: ${prefix}/${version}/reference/aggregation/ -> ${base}/${version}/interact-data/aggregation/ +[master]: ${prefix}/${version}/reference/map-reduce/ -> ${base}/${version}/interact-data/aggregation/ +[master]: ${prefix}/${version}/reference/persistence-configuration/ -> ${base}/${version}/configuration/persistence-config/ +[master]: ${prefix}/${version}/reference/nested-attributes/ -> ${base}/${version}/interact-data/nested-attributes/ +[master]: ${prefix}/${version}/reference/callbacks/ -> ${base}/${version}/data-modeling/callbacks/ +[master]: ${prefix}/${version}/reference/sessions/ -> ${base}/${version}/interact-data/transaction/ +[master]: ${prefix}/${version}/reference/transactions/ -> ${base}/${version}/interact-data/transaction/ +[master]: ${prefix}/${version}/release-notes/upgrading/ -> ${base}/${version}/whats-new/ +[master]: ${prefix}/${version}/release-notes/mongoid-9.0/ -> ${base}/${version}/whats-new/ +[master]: ${prefix}/${version}/contributing/code-documentation/ -> ${base}/${version}/code-documentation/ +[master]: ${prefix}/${version}/contributing/contributing-guidelines/ -> ${base}/${version}/issues-and-help/ +[master]: ${prefix}/${version}/additional-resources/ -> ${base}/${version}/integrations-tools/external-resources/ +[master]: ${prefix}/${version}/ecosystem/ -> ${base}/${version}/integrations-tools/external-resources/ diff --git a/source/api.txt b/source/api.txt index eb027514..8a1121db 100644 --- a/source/api.txt +++ b/source/api.txt @@ -12,4 +12,4 @@ API Documentation :maxdepth: 1 {+odm+} <{+api+}> - Ruby Driver <{+ruby-api+}> + {+language+} Driver <{+ruby-api+}> diff --git a/source/code-documentation.txt b/source/code-documentation.txt index dd18d384..5f10ea21 100644 --- a/source/code-documentation.txt +++ b/source/code-documentation.txt @@ -198,7 +198,8 @@ Type Declaration # @param [ Hash ] hash A Hash whose keys are Symbols, # and whose values are boolean values. -- **Ruby Values:** Specific values may be denoted in the type using Ruby syntax. +- **{+language+} Values:** Specific values may be denoted in the type + using {+language+} syntax. .. code-block:: ruby @@ -206,7 +207,7 @@ Type Declaration - **True, False, and Nil:** Use ``true``, ``false``, and ``nil`` rather than ``TrueClass``, ``FalseClass``, and ``NilClass``. Do not use ``Boolean`` as a type - since it does not exist in Ruby. + since it does not exist in {+language+}. .. code-block:: ruby diff --git a/source/compatibility.txt b/source/compatibility.txt index d44c016b..9ce29e41 100644 --- a/source/compatibility.txt +++ b/source/compatibility.txt @@ -38,7 +38,7 @@ MongoDB Compatibility The following compatibility table specifies the recommended version or versions of {+odm+} that you can use with a specific version of MongoDB. To use -features of a particular MongoDB Server version, both the +features of a particular {+mdb-server+} version, both the {+ruby-driver+} and {+odm+} must be compatible with that MongoDB version. To learn about the driver's MongoDB compatibility details, see :ruby:`Compatibility ` diff --git a/source/configuration/app-config.txt b/source/configuration/app-config.txt index 05ad16ea..013ecf56 100644 --- a/source/configuration/app-config.txt +++ b/source/configuration/app-config.txt @@ -331,14 +331,14 @@ functionality is provided by the {+ruby-driver+}, which implements the following supported algorithms: - `Zstandard `__ (*Recommended*): To use ``zstandard`` - compression, you must install the `zstd-ruby - `__ library. This compressor + compression, you must install the :rubygems:`zstd-ruby + ` library. This compressor produces the highest compression at the same CPU consumption compared to the other compressors. - :github:`Snappy `: To use ``snappy`` compression, you - must install the `snappy `__ library. + must install the :rubygems:`snappy ` library. - `Zlib `__: To use ``zlib`` compression, you - must install the `zlib `__ library. + must install the :rubygems:`zlib ` library. To use wire protocol compression, configure the driver options in your ``mongoid.yml`` file: @@ -359,4 +359,4 @@ use compression, even if the required dependencies for one or more compressors are installed. The driver chooses the first compressor, if you specify multiple, that -is supported by the MongoDB Server. +is supported by your MongoDB deployment. diff --git a/source/configuration/collection-config.txt b/source/configuration/collection-config.txt index 9d2c9e22..2cf28c06 100644 --- a/source/configuration/collection-config.txt +++ b/source/configuration/collection-config.txt @@ -29,7 +29,7 @@ Configure Collection Options You can specify configuration options for a collection by using the ``:collection_options`` argument with the ``store_in`` macro. The ``:collection_options`` argument accepts any collection option that -your {+ruby-driver+} and MongoDB server version supports. +your {+ruby-driver+} and {+mdb-server+} versions support. .. note:: diff --git a/source/configuration/persistence-config.txt b/source/configuration/persistence-config.txt index 06414b5b..5452de0b 100644 --- a/source/configuration/persistence-config.txt +++ b/source/configuration/persistence-config.txt @@ -30,8 +30,9 @@ the persistence configuration of a model class. .. note:: - "Client" refers to a host configuration defined under ``clients`` in your - ``mongoid.yml`` file. Most applications use a single client named ``default``. + The term "client" refers to a host configuration defined under + ``clients`` in your ``mongoid.yml`` file. Most applications use + a single client named ``default``. Default Collection Name ----------------------- @@ -48,12 +49,12 @@ the ``Person`` class, the corresponding collection is named ``people``. However, the default rules of pluralization don't always work. For example, suppose your model is named ``Rey``. The plural form of this word in -Spanish is "reyes," but the default collection name is "reys." +Spanish is ``reyes``, but the default collection name is ``reys``. You can create a new pluralization rule for your model class by calling the -`ActiveSupport::Inflector::Inflections.plural() `__ +`ActiveSupport::Inflector::Inflections.plural `__ instance method and passing the singular and plural forms of your class name. -The following example specifies "reyes" as the plural of "rey": +The following example specifies ``reyes`` as the plural of ``rey``: .. literalinclude:: /includes/configuration/persistence-configuration.rb :language: ruby @@ -65,8 +66,9 @@ collection. .. note:: BSON Document Structure - When {+odm+} stores a document in a database, it serializes the Ruby object - to a BSON document that has the following structure: + When {+odm+} stores a document in a database, it serializes the + {+language+} object to a BSON document that has the following + structure: .. literalinclude:: /includes/configuration/persistence-configuration.rb :language: ruby diff --git a/source/configuration/query-cache-config.txt b/source/configuration/query-cache-config.txt index ec89cd39..5f8aaefd 100644 --- a/source/configuration/query-cache-config.txt +++ b/source/configuration/query-cache-config.txt @@ -26,6 +26,8 @@ activate the :ref:`mongoid-query-cache` for each request to store your query results. This can improve your application speed and efficiency by reducing the number of calls your application must make to the database. +.. _mongoid-query-cache-rack: + Enable Query Cache for Rack Web Requests ---------------------------------------- diff --git a/source/configuration/sharding.txt b/source/configuration/sharding.txt index 95c259a0..140ea967 100644 --- a/source/configuration/sharding.txt +++ b/source/configuration/sharding.txt @@ -153,7 +153,6 @@ errors, check the output of the {+odm+} logger configured for your application. run the :manual:`flushRouterConfig ` command on each ``mongos`` node. - Additional Information ---------------------- diff --git a/source/data-modeling/associations.txt b/source/data-modeling/associations.txt index 88d65315..80afd719 100644 --- a/source/data-modeling/associations.txt +++ b/source/data-modeling/associations.txt @@ -73,7 +73,7 @@ class is present in your parent class, as shown in the following example: :emphasize-lines: 6 To learn more about validations in {+odm+}, see the :ref:`Validations -` guide. +` guide. Has Many ~~~~~~~~ @@ -110,7 +110,7 @@ class is present in your parent class, as shown in the following example: :emphasize-lines: 6 To learn more about validations in {+odm+}, see the :ref:`Validations -` guide. +` guide. Retrieve Association Information ```````````````````````````````` @@ -396,7 +396,7 @@ are embedded in a ``Band`` class. The query returns documents that have a :start-after: # start-embedded-query :end-before: # end-embedded-query -You can use the ``pluck()`` projection method to retrieve embedded documents +You can use the ``pluck`` projection method to retrieve embedded documents without retrieving their associated parent documents, as shown in the following example: @@ -434,13 +434,14 @@ Embedded matching on loaded documents has the following known limitations: - Embedded matching is not implemented for the following features: - - :ref:`Text search ` - - :manual:`Geospatial query operators ` - - Operators that execute JavaScript code, such as :manual:`$where ` + - :ref:`Text search ` + - :manual:`Geospatial queries ` + - Operators that execute JavaScript code, such as :manual:`$where + ` - Operators that are implemented through other server functionality, such as - :manual:`$expr ` + :manual:`$expr ` and :manual:`$jsonSchema - ` + ` - {+odm+} expands ``Range`` arguments to hashes with ``$gte`` and ``$lte`` conditions. This can lead to invalid queries in some cases and raises a an @@ -450,7 +451,7 @@ Embedded matching on loaded documents has the following known limitations: as a pattern while also providing options to the ``$options`` field. You can only provide options if the regular expression pattern is a string. -- MongoDB Server versions 4.0 and earlier do not strictly validate ``$type`` +- {+mdb-server+} versions 4.0 and earlier do not strictly validate ``$type`` arguments. Omit _id Fields @@ -477,14 +478,14 @@ Delete Embedded Associations You can delete child documents from ``embeds_many`` associations by using one of the following methods: -- ``clear()`` -- ``delete_all()`` -- ``destroy_all()`` +- ``clear`` +- ``delete_all`` +- ``destroy_all`` -The ``clear()`` method uses the :manual:`$unset operator +The ``clear`` method uses the :manual:`$unset operator ` operator to remove an entire embedded -association from the parent document. The ``clear()`` method does not run any -``destroy`` callbacks. The following example uses the ``clear()`` +association from the parent document. The ``clear`` method does not run any +``destroy`` callbacks. The following example uses the ``clear`` method to remove all embedded associations from the ``Band`` class: .. literalinclude:: /includes/data-modeling/associations.rb @@ -492,12 +493,12 @@ method to remove all embedded associations from the ``Band`` class: :start-after: # start-embedded-clear :end-before: # end-embedded-clear -The ``delete_all()`` method uses the :manual:`$pullAll operator +The ``delete_all`` method uses the :manual:`$pullAll operator ` operator to remove documents in an -embedded association. ``delete_all()`` loads the association if it has not +embedded association. ``delete_all`` loads the association if it has not yet been loaded, then only removes the documents that exist in the application. -The ``delete_all()`` method does not run any ``destroy`` callbacks. -The following example uses the ``delete_all()`` method to remove all embedded +The ``delete_all`` method does not run any ``destroy`` callbacks. +The following example uses the ``delete_all`` method to remove all embedded ``Album`` documents from the ``Band`` class: .. literalinclude:: /includes/data-modeling/associations.rb @@ -505,10 +506,10 @@ The following example uses the ``delete_all()`` method to remove all embedded :start-after: # start-embedded-delete-all :end-before: # end-embedded-delete-all -The ``destroy_all()`` method also uses the :manual:`$pullAll operator +The ``destroy_all`` method also uses the :manual:`$pullAll operator ` operator to remove documents in an embedded association. It also runs any ``destroy`` callbacks that are defined on -the associated documents. The following example uses the ``destroy_all()`` +the associated documents. The following example uses the ``destroy_all`` method to remove all embedded ``Album`` documents from the ``Band`` class: .. literalinclude:: /includes/data-modeling/associations.rb diff --git a/source/data-modeling/documents.txt b/source/data-modeling/documents.txt index 97442968..f1e06630 100644 --- a/source/data-modeling/documents.txt +++ b/source/data-modeling/documents.txt @@ -86,10 +86,11 @@ The document appears in MongoDB as follows: Additional Information ---------------------- +To learn more about the field types that you can use in {+odm+} models, see +the :ref:`mongoid-field-types` guide. + To learn how to access and change your MongoDB data, see the :ref:`mongoid-interact-data` guides. To learn more about how to model your data by using {+odm+} models, see the :ref:`mongoid-data-modeling` guides. - -.. TODO Add link to field types guide. diff --git a/source/data-modeling/field-behaviors.txt b/source/data-modeling/field-behaviors.txt index daf9dc23..5600af31 100644 --- a/source/data-modeling/field-behaviors.txt +++ b/source/data-modeling/field-behaviors.txt @@ -83,6 +83,8 @@ following example: Always set the ``pre-processed`` option to ``true`` to set a default ``Proc`` value for the ``_id`` field. +.. _mongoid-field-behaviors-storage-names: + Specify Storage Names --------------------- @@ -103,6 +105,8 @@ following example creates a field called ``name`` that {+odm+} stores in the dat {+odm+} stores the ``name`` field as ``"n"``, but you can still access the field as ``name`` in your application. +.. _mongoid-field-behaviors-aliases: + Field Aliases ------------- @@ -222,11 +226,15 @@ you attempt to explicitly update a read-only field, {+odm+} raises a Calls to atomic persistence operators, such as ``bit`` and ``inc``, still persist changes to the read-only field. +To learn about specifying entire models as read-only, see the +:ref:`mongoid-crud-read-only` section of the Perform Data Operations +guide. + Localize Fields --------------- -{+odm+} supports localized fields by using the `i18n gem -`__. When you localize a field, {+odm+} +{+odm+} supports localized fields by using the :github:`i18n gem +`. When you localize a field, {+odm+} stores the field as a hash of locale keys and values. Accessing the fields behaves in the same way as a string value. You can localize fields of any field type. @@ -247,8 +255,8 @@ method: :start-after: # start-localized-translations :end-before: # end-localized-translations -You can specify fallbacks for localized fields by enabling the `i18n fallbacks -`__ feature. +You can specify fallbacks for localized fields by enabling the +:github:`i18n fallbacks ` feature. Enable fallbacks in a Rails application by setting the ``config.i18n.fallbacks`` configuration setting in your environment and setting the fallback languages: diff --git a/source/data-modeling/field-types.txt b/source/data-modeling/field-types.txt index 1d4df189..5967162e 100644 --- a/source/data-modeling/field-types.txt +++ b/source/data-modeling/field-types.txt @@ -30,7 +30,8 @@ when retrieving a document from the database, {+odm+} translates a BSON ``double`` type to use the {+language+} ``Float`` type. When you save the document again, {+odm+} converts the field back to a BSON ``double``. -.. TODO: To learn more about modeling documents in {+odm+}, see :ref:`mongoid-modeling-documents`. +To learn more about modeling documents in {+odm+}, see the +:ref:`mongoid-modeling-documents` guide. .. note:: @@ -134,10 +135,8 @@ Time You can store values as BSON ``Time`` instances by using the ``Time`` field value. ``Time`` fields are stored in the time zone configured for your application. To -learn more about configuring time zones, see the :ref:`Time Zones ` -guide. - -.. TODO: Update Time Zones guide ref if it's changed during standardization +learn more about configuring time zones, see the :ref:`mongoid-config-time-zones` +section of the Application Configuration guide. The following example creates a ``Voter`` class and specifies that the value of the ``registered_at`` field is a ``Time`` type: @@ -151,11 +150,10 @@ The following example creates a ``Voter`` class and specifies that the value of Storing a ``Date`` or ``DateTime`` value in a field specified as ``Time`` converts the value to ``Time`` when assigned. If you store a string in a - ``Time`` field, {+odm+} parses the string by using the ``Time.parse()`` - method. - -.. TODO: Add this to the note: -.. To learn more about how {+odm+} converts queries, see :ref:`` + ``Time`` field, {+odm+} parses the string by using the ``Time.parse`` + method. To learn more about how {+odm+} converts queries, see the + :ref:`mongoid-query-field-type-conversions` section of the Specify a + Query guide. Date ~~~~ @@ -182,12 +180,11 @@ to ``Date`` before assigning them to the field. .. note:: When a database contains a string value for a ``Date`` field, the driver - parses the value by using the ``Time.parse()`` method, then discards the time - portion. ``Time.parse()`` considers values without time zones to be in local - time. - -.. TODO: Add this to the note: -.. To learn more about how {+odm+} converts queries, see :ref:`` + parses the value by using the ``Time.parse`` method, then discards the time + portion. ``Time.parse`` considers values without time zones to be in local + time. To learn more about how {+odm+} converts queries, see the + :ref:`mongoid-query-field-type-conversions` section of the Specify a + Query guide. DateTime ~~~~~~~~ @@ -224,14 +221,12 @@ value by using the timezone configured as the default for your application: :start-after: # start-datetime-string :end-before: # end-datetime-string -To learn more about configuring time zones, see the :ref:`Time Zones ` -guide. - -.. TODO: Update Time Zones guide ref if it's changed during standardization +To learn more about configuring time zones, see the :ref:`mongoid-config-time-zones` +section of the Application Configuration guide. .. note:: - {+odm+} parses string values into ``DateTime`` by using the ``Time.parse()`` + {+odm+} parses string values into ``DateTime`` by using the ``Time.parse`` method, which considers values without time zones to be in local time. Timestamps @@ -270,7 +265,7 @@ the ``::Short`` option when including the module: :end-before: # end-timestamps-short You can disable creating the timestamp field for specific operations by calling -the ``timeless()`` method on the method call. The following example disables the +the ``timeless`` method on the method call. The following example disables the timestamps for the ``save`` operation: .. literalinclude:: /includes/data-modeling/field-types.rb @@ -284,7 +279,7 @@ Regexp You can store regular expressions in a field by using the ``Regexp`` type. While MongoDB implements `Perl Compatible Regular Expressions (PCRE) `__, -{+odm+} uses {+language+}'s `Onigmo `__ library. PCRE and +{+odm+} uses {+language+}'s :github:`Onigmo ` library. PCRE and Onigmo provide generally similar functionality, but there are several syntax differences. For example, Onigmo uses ``\A`` and ``\z`` to match the beginning and end of a string, while PCRE uses ``^`` and ``$``. @@ -292,7 +287,7 @@ end of a string, while PCRE uses ``^`` and ``$``. When you declare a field as a ``Regexp``, {+odm+} converts {+language+} regular expressions to BSON regular expressions when storing the result into your database. The database returns the field as a ``Bson::Regexp::Raw`` instance. -You can use the ``compile()`` method on ``BSON::Regexp::Raw`` instances to convert +You can use the ``compile`` method on ``BSON::Regexp::Raw`` instances to convert the data back to a {+language+} regular expression. The following example creates a ``Token`` class and specifies the ``pattern`` @@ -307,9 +302,9 @@ field as a ``Regexp``: Converting a BSON regular expression to a {+language+} regular expression might produce a different regular expression than the original. This difference is - due to the differences between the Onigmo and PCRE syntaxes. - -.. TODO: To learn more about regular expressions in {+odm+}, see :ref:`mongoid-regular-expressions`. + due to the differences between the Onigmo and PCRE syntaxes. To learn + more about regular expressions in {+odm+}, see the + :ref:`mongoid-query-regex` section of the Specify a Query guide. BigDecimal ~~~~~~~~~~ @@ -472,11 +467,11 @@ You can create custom field types and define how {+odm+} serializes and deserializes them. To create a custom field type, define a class that implements the following methods: -- ``mongoize()``: Takes an instance of your custom type and converts it to +- ``mongoize``: Takes an instance of your custom type and converts it to an object that MongoDB can store. -- ``demongoize()``: Takes an object from MongoDB and converts it to an +- ``demongoize``: Takes an object from MongoDB and converts it to an instance of your custom type. -- ``evolve()``: Takes an instance of your custom type and converts it to a +- ``evolve``: Takes an instance of your custom type and converts it to a criteria that MongoDB can use to query the database. The following example creates a custom field type called ``Point`` and @@ -487,16 +482,16 @@ implements the preceding methods: :start-after: # start-custom-field-type :end-before: # end-custom-field-type -In the preceding example, the ``mongoize()`` *instance method* accepts an instance +In the preceding example, the ``mongoize`` *instance method* accepts an instance of your custom type object and converts it to an ``Array`` to store in the -database. The ``mongoize()`` *class method* accepts objects of all types and +database. The ``mongoize`` *class method* accepts objects of all types and converts them to similar types that can be stored in the database. {+odm+} uses -the ``mongoize()`` class method when it calls the getter and setter methods. +the ``mongoize`` class method when it calls the getter and setter methods. -The ``demongoize()`` method converts the stored ``Array`` value into the custom +The ``demongoize`` method converts the stored ``Array`` value into the custom ``Point`` type. The {+odm+} uses this method when it calls the getter. -The ``evolve()`` method converts the custom ``Point`` type into a queryable +The ``evolve`` method converts the custom ``Point`` type into a queryable ``Array`` type, and converts all other types to ``object``. {+odm+} uses this method when it calls a method that queries the database. @@ -516,10 +511,12 @@ color in the application, but stores the color as an integer in the database: :start-after: # start-phantom-field-type :end-before: # end-phantom-field-type +.. _mongoid-field-types-dynamic: + Dynamic Fields -------------- -You can instruct {+odm+} to create fields dynamically by inluding the +You can instruct {+odm+} to create fields dynamically by including the ``Mongoid::Attributes::Dynamic`` module in your model. This allows {+odm+} to create fields based on an arbitrary hash, or based on the documents already stored in the database. @@ -558,24 +555,19 @@ string to indicate a query operator. Because of this, you should avoid using the characters in your field names. If your application requires the use of these characters, you can access the -fields by calling the ``send()`` method. The following example creates a ``User`` +fields by calling the ``send`` method. The following example creates a ``User`` class with fields that contain reserved characters. It then accesses the fields -by using the ``send()`` method: +by using the ``send`` method: .. literalinclude:: /includes/data-modeling/field-types.rb :language: ruby :start-after: # start-reserved-characters :end-before: # end-reserved-characters -You can also access these fields by calling the ``read_attribute()`` method. +You can also access these fields by calling the ``read_attribute`` method. .. important:: Because updating and replacing fields containing these reserved characters requires special operators, calling getters and setters on these fields raises an ``InvalidDotDollarAssignment`` exception. - -.. Additional Information -.. ---------------------- - -.. TODO: Add Additional Information section with links to relevant pages once they are standardized diff --git a/source/data-modeling/indexes.txt b/source/data-modeling/indexes.txt index 736e0141..dcf39899 100644 --- a/source/data-modeling/indexes.txt +++ b/source/data-modeling/indexes.txt @@ -1,4 +1,5 @@ .. _mongoid-optimize-queries-with-indexes: +.. _mongoid-indexes: ============================= Optimize Queries With Indexes diff --git a/source/data-modeling/inheritance.txt b/source/data-modeling/inheritance.txt index 26654874..08441ffd 100644 --- a/source/data-modeling/inheritance.txt +++ b/source/data-modeling/inheritance.txt @@ -104,7 +104,7 @@ You might change the discriminator key from the default field name You can change the discriminator key on the class level or on the global level. To change the discriminator key on the class level, you can set the custom key name on the parent class by using the -``discriminator_key()`` method. +``discriminator_key`` method. The following example demonstrates how to set a custom discriminator key when defining a model class: @@ -166,7 +166,7 @@ Change the Discriminator Value ------------------------------ You can customize the value that {+odm+} sets as the discriminator value -in MongoDB. Use the ``discriminator_value()`` method when defining a +in MongoDB. Use the ``discriminator_value`` method when defining a class to customize the discriminator value, as shown in the following example: @@ -201,9 +201,9 @@ Embedded Associations --------------------- You can create any type of parent class or child class in an embedded -association by assignment or by using the ``build()`` and ``create()`` +association by assignment or by using the ``build`` and ``create`` methods. You can pass desired model class as the second parameter to the -``build()`` and ``create()`` methods to instruct {+odm+} to create that +``build`` and ``create`` methods to instruct {+odm+} to create that specific instance as an emdedded document. The following code creates an instance of ``Employee``, then @@ -262,12 +262,12 @@ Persistence Contexts You can change the persistence context of a child class from the persistence context of its parent to store the document in a -different location than the default. By using the ``store_in()`` method, +different location than the default. By using the ``store_in`` method, you can store an instance of a child class in a different collection, database, or cluster than an instance of the parent model. The following model definitions demonstrate how to use the -``store_in()`` method to store instances of ``Employee`` and ``Manager`` +``store_in`` method to store instances of ``Employee`` and ``Manager`` in a different collection than the ``people`` collection: .. code-block:: ruby @@ -304,4 +304,5 @@ are stored in the collection associated with the parent class. Additional Information ---------------------- -.. TODO add links to persistence docs +To learn more about configuring the target collection for your +operations, see the :ref:`mongoid-persistence` guide. diff --git a/source/data-modeling/validation.txt b/source/data-modeling/validation.txt index 6909df02..96ac5474 100644 --- a/source/data-modeling/validation.txt +++ b/source/data-modeling/validation.txt @@ -255,9 +255,8 @@ Validate Associations You can use the ``validates_associated`` helper to validate any associations that your model has. When you include this validation rule, {+odm+} validates any association documents any time you try to -save an instance. - -.. TODO link to associations page +save an instance. To learn more about associations, see the +:ref:`mongoid-associations` guide. This example defines an association validation rule on the ``Author`` model to run the validation rules for the embedded ``Book`` @@ -301,9 +300,9 @@ Behavior database. The following methods trigger your validation rules, so {+odm+} saves the object to the database only if it passes validation: -- ``create()`` -- ``save()`` -- ``update()`` +- ``create`` +- ``save`` +- ``update`` When you use the ``!``-suffixed version of the preceding methods, {+odm+} returns an ``Mongoid::Errors::Validations`` exception if @@ -312,7 +311,7 @@ validation fails for an object. Trigger Validation ~~~~~~~~~~~~~~~~~~ -You can run validations manually by using the ``valid?()`` method. This +You can run validations manually by using the ``valid?`` method. This method returns ``true`` if the object passes validation, and ``false`` otherwise: @@ -323,14 +322,17 @@ method returns ``true`` if the object passes validation, and :emphasize-lines: 7, 11, 14 :dedent: -{+odm+} behaves differently from Active Record when running ``valid?()`` -on persisted data. Active Record's ``valid?()`` runs all -validations, but {+odm+}'s ``valid?()`` runs validations only on +{+odm+} behaves differently from Active Record when running ``valid?`` +on persisted data. Active Record's ``valid?`` runs all +validations, but {+odm+}'s ``valid?`` runs validations only on documents that are in memory to optimize performance. Additional Information ---------------------- +To learn more about the field types that you can use in {+odm+} models, see +the :ref:`mongoid-field-types` guide. + To learn more about validation methods and macros in {+odm+}, see the :mongoid-api:`Mongoid::Validatable ` module reference in the API documentation. @@ -339,5 +341,3 @@ To view a full list of validations helpers in Active Record, see the `ActiveModel::Validations::HelperMethods `__ reference in the Rails API documentation. - -.. TODO link to field types guide. diff --git a/source/includes/data-modeling/field-behaviors.rb b/source/includes/data-modeling/field-behaviors.rb index 94e9d4dd..f1f59e47 100644 --- a/source/includes/data-modeling/field-behaviors.rb +++ b/source/includes/data-modeling/field-behaviors.rb @@ -1,22 +1,22 @@ # start-field-default class Order - include Mongoid::Document + include Mongoid::Document - field :state, type: String, default: 'created' + field :state, type: String, default: 'created' end # end-field-default # start-field-default-processed class Order - include Mongoid::Document + include Mongoid::Document - field :fulfill_by, type: Time, default: ->{ Time.now + 3.days } + field :fulfill_by, type: Time, default: ->{ Time.now + 3.days } end # end-field-default-processed # start-field-default-self field :fulfill_by, type: Time, default: ->{ - self.submitted_at + 4.hours + self.submitted_at + 4.hours } # end-field-default-self @@ -27,56 +27,56 @@ class Order # start-field-as class Band - include Mongoid::Document - field :n, as: :name, type: String + include Mongoid::Document + field :n, as: :name, type: String end # end-field-as # start-field-alias class Band - include Mongoid::Document - field :name, type: String - alias_attribute :n, :name + include Mongoid::Document + field :name, type: String + alias_attribute :n, :name end # end-field-alias # start-field-unalias class Band - unalias_attribute :n + unalias_attribute :n end # end-field-unalias # start-field-overwrite class Person - include Mongoid::Document - field :name - field :name, type: String, overwrite: true + include Mongoid::Document + field :name + field :name, type: String, overwrite: true end # end-field-overwrite # start-custom-id class Band - include Mongoid::Document - field :name, type: String - field :_id, type: String, default: ->{ name } + include Mongoid::Document + field :name, type: String + field :_id, type: String, default: ->{ name } end # end-custom-id # start-custom-getter-setter class Person - include Mongoid::Document - field :name, type: String + include Mongoid::Document + field :name, type: String - # Custom getter for 'name' to return the name in uppercase - def name - read_attribute(:name).upcase if read_attribute(:name) - end + # Custom getter for 'name' to return the name in uppercase + def name + read_attribute(:name).upcase if read_attribute(:name) + end - # Custom setter for 'name' to store the name in lowercase - def name=(value) - write_attribute(:name, value.downcase) - end + # Custom setter for 'name' to store the name in lowercase + def name=(value) + write_attribute(:name, value.downcase) end +end # end-custom-getter-setter # start-localized-field diff --git a/source/includes/data-modeling/indexes.rb b/source/includes/data-modeling/indexes.rb index 9eebaab9..ab68b9ca 100644 --- a/source/includes/data-modeling/indexes.rb +++ b/source/includes/data-modeling/indexes.rb @@ -1,12 +1,12 @@ # start create index class Restaurant - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :cuisine, type: String - field :borough, type: String + field :name, type: String + field :cuisine, type: String + field :borough, type: String - index({ cuisine: 1}, { name: "cuisine_index", unique: false }) + index({ cuisine: 1}, { name: "cuisine_index", unique: false }) end Restaurant.create_indexes @@ -14,72 +14,72 @@ class Restaurant # start create alias index class Restaurant - include Mongoid::Document + include Mongoid::Document - field :borough, as: :b + field :borough, as: :b - index({ b: 1}, { name: "borough_index" }) + index({ b: 1}, { name: "borough_index" }) end # end create alias index # start create embedded index class Address - include Mongoid::Document + include Mongoid::Document - field :street, type: String + field :street, type: String end class Restaurant - include Mongoid::Document + include Mongoid::Document - embeds_many :addresses - index({"addresses.street": 1}) + embeds_many :addresses + index({"addresses.street": 1}) end # end create embedded index # start create compound index class Restaurant - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :borough, type: String + field :name, type: String + field :borough, type: String - index({borough: 1, name: -1}, { name: "compound_index"}) + index({borough: 1, name: -1}, { name: "compound_index"}) end # end create compound index # start create 2dsphere index class Restaurant - include Mongoid::Document + include Mongoid::Document - field :location, type: Array + field :location, type: Array - index({location: "2dsphere"}, { name: "location_index"}) + index({location: "2dsphere"}, { name: "location_index"}) end # end create 2dsphere index # start create sparse index class Restaurant - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :cuisine, type: String - field :borough, type: String + field :name, type: String + field :cuisine, type: String + field :borough, type: String - index({ borough: 1}, { sparse: true }) + index({ borough: 1}, { sparse: true }) end # end create sparse index # start create multiple indexes class Restaurant - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :cuisine, type: String - field :borough, type: String - - index({ name: 1}) - index({ cuisine: -1}) + field :name, type: String + field :cuisine, type: String + field :borough, type: String + + index({ name: 1}) + index({ cuisine: -1}) end Restaurant.create_indexes @@ -91,24 +91,24 @@ class Restaurant # start create atlas search index class Restaurant - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :cuisine, type: String - field :borough, type: String - - search_index :my_search_index, - mappings: { - fields: { - name: { - type: "string" - }, - cuisine: { - type: "string" - } - }, - dynamic: true - } + field :name, type: String + field :cuisine, type: String + field :borough, type: String + + search_index :my_search_index, + mappings: { + fields: { + name: { + type: "string" + }, + cuisine: { + type: "string" + } + }, + dynamic: true + } end Restaurant.create_search_indexes @@ -120,4 +120,4 @@ class Restaurant #start list atlas search index Restaurant.search_indexes.each { |index| puts index } -# end list atlas search index \ No newline at end of file +# end list atlas search index diff --git a/source/includes/data-modeling/nested_attr.rb b/source/includes/data-modeling/nested_attr.rb index e81a4c4d..d71f613b 100644 --- a/source/includes/data-modeling/nested_attr.rb +++ b/source/includes/data-modeling/nested_attr.rb @@ -18,8 +18,8 @@ class Band band = Band.create( name: 'Tennis', albums_attributes: [ - { name: 'Swimmer', year: 2020 }, - { name: 'Young & Old', year: 2013 }] + { name: 'Swimmer', year: 2020 }, + { name: 'Young & Old', year: 2013 }] ) # end-create-attr @@ -36,7 +36,7 @@ class Band album = band.albums.first # Updates the entry by passing the _id value band.update(albums_attributes: [ - { _id: album._id, year: 2011 } ]) + { _id: album._id, year: 2011 } ]) # end-update-id # start-delete-id @@ -45,14 +45,14 @@ class Band album = band.albums.first # Deletes the entry by passing the _id value band.update(albums_attributes: [ - { _id: album._id, _destroy: true } ]) + { _id: album._id, _destroy: true } ]) # end-delete-id # start-multiple-ops band = Band.where(name: 'Yeah Yeah Yeahs').first # Performs multiple data changes band.update(albums_attributes: [ - { name: 'Show Your Bones', year: 2006 }, - { _id: 1, name: 'Fever To T3ll' }, - { _id: 2, _destroy: true } ]) + { name: 'Show Your Bones', year: 2006 }, + { _id: 1, name: 'Fever To T3ll' }, + { _id: 2, _destroy: true } ]) # end-multiple-ops \ No newline at end of file diff --git a/source/includes/interact-data/scoping.rb b/source/includes/interact-data/scoping.rb index 2e1889a7..1a6f7631 100644 --- a/source/includes/interact-data/scoping.rb +++ b/source/includes/interact-data/scoping.rb @@ -1,12 +1,12 @@ # start-named-scope-1 class Band - include Mongoid::Document + include Mongoid::Document - field :country, type: String - field :genres, type: Array + field :country, type: String + field :genres, type: Array - scope :japanese, ->{ where(country: "Japan") } - scope :rock, ->{ where(:genres.in => [ "rock" ]) } + scope :japanese, ->{ where(country: "Japan") } + scope :rock, ->{ where(:genres.in => [ "rock" ]) } end # end-named-scope-1 @@ -16,12 +16,12 @@ class Band # start-named-scope-2 class Band - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :country, type: String + field :name, type: String + field :country, type: String - scope :based_in, ->(country){ where(country: country) } + scope :based_in, ->(country){ where(country: country) } end # end-named-scope-2 @@ -31,35 +31,35 @@ class Band # start-named-scope-3 class Band - include Mongoid::Document + include Mongoid::Document - def self.on_tour - true - end + def self.on_tour + true + end - scope :on_tour, ->{ where(on_tour: true) } + scope :on_tour, ->{ where(on_tour: true) } end # end-named-scope-3 # start-default-scope-1 class Band - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :active, type: Boolean + field :name, type: String + field :active, type: Boolean - default_scope -> { where(active: true) } + default_scope -> { where(active: true) } end # end-default-scope-1 # start-default-scope-2 class Band - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :on_tour, type: Boolean, default: true + field :name, type: String + field :on_tour, type: Boolean, default: true - default_scope ->{ where(on_tour: false) } + default_scope ->{ where(on_tour: false) } end # Creates a new Band instance in which "on_tour" is "false" @@ -78,11 +78,11 @@ class Band # start-scope-association class Label - include Mongoid::Document + include Mongoid::Document - field :name, type: String + field :name, type: String - embeds_many :bands + embeds_many :bands end class Band @@ -112,13 +112,13 @@ class Band # start-scope-query-behavior class Band - include Mongoid::Document + include Mongoid::Document - field :name - field :touring - field :member_count + field :name + field :touring + field :member_count - default_scope ->{ where(touring: true) } + default_scope ->{ where(touring: true) } end # Combines the condition to the default scope with "and" @@ -139,31 +139,31 @@ class Band # start-override-scope class Band - include Mongoid::Document + include Mongoid::Document - field :country, type: String - field :genres, type: Array + field :country, type: String + field :genres, type: Array - scope :mexican, ->{ where(country: "Mexico") } + scope :mexican, ->{ where(country: "Mexico") } end # end-override-scope # start-override-scope-block Band.with_scope(Band.mexican) do - Band.all + Band.all end # end-override-scope-block # start-class-methods class Band - include Mongoid::Document + include Mongoid::Document - field :name, type: String - field :touring, type: Boolean, default: true + field :name, type: String + field :touring, type: Boolean, default: true - def self.touring - where(touring: true) - end + def self.touring + where(touring: true) + end end Band.touring diff --git a/source/includes/interact-data/transaction.rb b/source/includes/interact-data/transaction.rb index ad8a74de..7f2f9354 100644 --- a/source/includes/interact-data/transaction.rb +++ b/source/includes/interact-data/transaction.rb @@ -1,26 +1,26 @@ # start-example-models class Book - include Mongoid::Document + include Mongoid::Document - field :title, type: String - field :author, type: String - field :length, type: Integer + field :title, type: String + field :author, type: String + field :length, type: Integer end class Film - include Mongoid::Document + include Mongoid::Document - field :title, type: String - field :year, type: Integer + field :title, type: String + field :year, type: Integer end # end-example-models # start-txn-operations # Starts a transaction from the model class Book.transaction do - # Saves new Book and Film instances to MongoDB - Book.create(title: 'Covert Joy', author: 'Clarice Lispector') - Film.create(title: 'Nostalgia', year: 1983) + # Saves new Book and Film instances to MongoDB + Book.create(title: 'Covert Joy', author: 'Clarice Lispector') + Film.create(title: 'Nostalgia', year: 1983) end # Starts a transaction from an instance of Book diff --git a/source/includes/security/encryption.rb b/source/includes/security/encryption.rb index e2ee5555..1fd9290d 100644 --- a/source/includes/security/encryption.rb +++ b/source/includes/security/encryption.rb @@ -11,19 +11,19 @@ class Patient # This field is encrypted by using AEAD_AES_256_CBC_HMAC_SHA_512-Random # algorithm field :passport_id, type: String, encrypt: { - deterministic: false + deterministic: false } # This field is encrypted by using AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic # algorithm field :blood_type, type: String, encrypt: { - deterministic: true + deterministic: true } # This field is encrypted by using AEAD_AES_256_CBC_HMAC_SHA_512-Random # algorithm and a different data key field :ssn, type: Integer, encrypt: { - deterministic: false, key_id: '`__, - `ActiveStorage `__, and + `ActiveStorage <{+active-record-docs+}/active_storage_overview.html>`__, and `ActionMailbox <{+active-record-docs+}/action_mailbox_basics.html>`__ adapters cannot be used alongside {+odm+}. @@ -159,7 +159,7 @@ When creating {+odm+} models, you can define fields in the following ways: - Define fields explicitly -- Use :ref:`dynamic fields ` +- Use :ref:`dynamic fields ` For example, a basic Active Record ``Post`` model might resemble the following: diff --git a/source/integrations-tools/external-resources.txt b/source/integrations-tools/external-resources.txt index 20994095..01a0f4fc 100644 --- a/source/integrations-tools/external-resources.txt +++ b/source/integrations-tools/external-resources.txt @@ -33,59 +33,59 @@ or built on top of {+odm+}. Projects ~~~~~~~~ -- `Workarea Commerce `__ is an +- :github:`Workarea Commerce ` is an enterprise-grade {+ror+} commerce platform that uses {+odm+}. Extension Libraries ~~~~~~~~~~~~~~~~~~~ -- `Mongoid Tree `__ is a tree structure +- :github:`Mongoid Tree ` is a tree structure for {+odm+} documents that uses the materialized path pattern. -- `Mongoid Token `__ generates random, - tokens for {+odm+} documents. +- :github:`Mongoid Token ` generates random, + unique tokens for {+odm+} documents. -- `Mongoid Collection Snapshot - `__ helps maintain +- :github:`Mongoid Collection Snapshot + ` helps maintain collections of processed data in {+odm+} applications. -- `Mongoid Locker `__ provides +- :github:`Mongoid Locker ` provides document-level locking for {+odm+} applications. -- `Mongo Beautiful Logger - `__ is a library that +- :github:`Mongo Beautiful Logger + ` is a library that formats your MongoDB logs. -- `Mongoid Search `__ provides +- :github:`Mongoid Search ` provides full-text search for {+odm+}. -- `Mongoid Fulltext Search `__ +- :github:`Mongoid Fulltext Search ` provides full-text search using n-gram matching for {+odm+}. Integration Libraries ~~~~~~~~~~~~~~~~~~~~~ -- `CarrierWave Mongoid - `__ provides +- :github:`CarrierWave Mongoid + ` provides {+odm+} support for the Carrierwave file-uploads library. -- `Mongoid RSpec `__ provides RSpec +- :github:`Mongoid RSpec ` provides RSpec matchers and macros for {+odm+} applications. -- `RailsAdmin `__ is a Rails engine that +- :github:`RailsAdmin ` is a Rails engine that provides an interface for managing your data. -- `ActiveAdmin Mongoid `__ +- :github:`ActiveAdmin Mongoid ` provides ActiveAdmin hacks to support {+odm+}. -- `Mongoid History `__ is a +- :github:`Mongoid History ` is a multi-user, non-linear history tracker for {+odm+}. -- `Delayed Job Mongoid - `__ is a {+odm+} backend for +- :github:`Delayed Job Mongoid + ` is a {+odm+} backend for ``delayed_job``. -- `Mongo Session Store `__ is a +- :github:`Mongo Session Store ` is a Rails-compatible session store for {+odm+}. Learning Resources @@ -112,7 +112,7 @@ Articles `__: Building a content management application with Sinatra and {+odm+}. -- `How To Create A Ruby API With Sinatra +- `How to Create a {+language+} API With Sinatra `__: Creating a Sinatra API with {+odm+}. @@ -123,5 +123,5 @@ Articles Sample Applications ~~~~~~~~~~~~~~~~~~~ -- `Mongoid Demo `__: A repository - containing sample applications that use {+odm+}. \ No newline at end of file +- :github:`Mongoid Demo `: A repository + containing sample applications that use {+odm+}. diff --git a/source/integrations-tools/rails-integration.txt b/source/integrations-tools/rails-integration.txt index ff703625..1861d47b 100644 --- a/source/integrations-tools/rails-integration.txt +++ b/source/integrations-tools/rails-integration.txt @@ -39,8 +39,8 @@ initializer in the ``config/initializers/mongoid.rb`` file. ``mongoid.yml`` as the default location for {+odm+} configuration when possible. -.. TODO To learn more about available configuration options, - see the :ref:`` section. +To learn more about all available configuration options, +see the :ref:`mongoid-configuration` guides. The following code demonstrates how to create a Rails logger by accessing ``config.mongoid``: @@ -53,7 +53,8 @@ accessing ``config.mongoid``: end end -.. TODO To learn more about logging settings, see the :ref:`` guide. +To learn more about logging settings, see the +:ref:`mongoid-logging-config` guide. Model Preloading ---------------- @@ -98,7 +99,7 @@ This logging is set up automatically in your Rails application. The time indicated in log entries is the time that the MongoDB deployment takes to run MongoDB operations in addition to the time taken to - send commands and receive results from the MongoDB Server. It does + send commands and receive results from {+mdb-server+}. It does not include time taken by the driver and {+odm+} to generate the queries, cast types, or otherwise process the results. diff --git a/source/interact-data/aggregation.txt b/source/interact-data/aggregation.txt index a30317f2..a5b1f6f4 100644 --- a/source/interact-data/aggregation.txt +++ b/source/interact-data/aggregation.txt @@ -86,19 +86,19 @@ pipeline operators: - Method Name * - :manual:`$group ` - - ``group()`` + - ``group`` * - :manual:`$project ` - - ``project()`` + - ``project`` * - :manual:`$unwind ` - - ``unwind()`` + - ``unwind`` To create an aggregation pipeline by using one of the preceding operators, call the corresponding method on an instance of ``Criteria``. Calling the method adds the aggregation operation to the ``pipeline`` atrritbure of the ``Criteria`` instance. To run the aggregation pipeline, pass the ``pipeline`` attribute value -to the ``Collection#aggregate()`` method. +to the ``Collection#aggregate`` method. Example ~~~~~~~ @@ -133,12 +133,12 @@ The following example creates an aggregation pipeline that outputs the states a participant has visited by using the following aggregation operations: -- ``match()``, which find documents in which the ``participants.name`` field +- ``match``, which find documents in which the ``participants.name`` field value is ``"Serenity"`` -- ``unwind()``, which deconstructs the ``states`` array field and outputs a +- ``unwind``, which deconstructs the ``states`` array field and outputs a document for each element in the array -- ``group()``, which groups the documents by the value of their ``states`` field -- ``project()``, which prompts the pipeline to return only the ``_id`` and +- ``group``, which groups the documents by the value of their ``states`` field +- ``project``, which prompts the pipeline to return only the ``_id`` and ``states`` fields .. io-code-block:: @@ -153,7 +153,7 @@ aggregation operations: Aggregation without Builders ---------------------------- -You can use the ``Collection#aggregate()`` method to run aggregation operations that do not have +You can use the ``Collection#aggregate`` method to run aggregation operations that do not have corresponding builder methods by passing in an array of aggregation operations. Using this method to perform the aggregation returns raw ``BSON::Document`` objects rather than ``Mongoid::Document`` model @@ -227,6 +227,6 @@ API Documentation To learn more about any of the methods discussed in this guide, see the following API documentation: -- `group() <{+api+}/Mongoid/Criteria/Queryable/Aggregable.html#group-instance_method>`__ -- `project() <{+api+}/Mongoid/Criteria/Queryable/Aggregable.html#project-instance_method>`__ -- `unwind() <{+api+}/Mongoid/Criteria/Queryable/Aggregable.html#unwind-instance_method>`__ \ No newline at end of file +- `group <{+api+}/Mongoid/Criteria/Queryable/Aggregable.html#group-instance_method>`__ +- `project <{+api+}/Mongoid/Criteria/Queryable/Aggregable.html#project-instance_method>`__ +- `unwind <{+api+}/Mongoid/Criteria/Queryable/Aggregable.html#unwind-instance_method>`__ \ No newline at end of file diff --git a/source/interact-data/crud.txt b/source/interact-data/crud.txt index 26cc04fe..846c1be6 100644 --- a/source/interact-data/crud.txt +++ b/source/interact-data/crud.txt @@ -135,6 +135,7 @@ Read Operations --------------- You can perform read operations to retrieve documents from a collection. +To learn more about creating query filters to retrieve a subset of your documents, see the :ref:`mongoid-data-specify-query` guide. .. _mongoid-read-attributes: @@ -773,6 +774,8 @@ model and assign it back to the model as shown in the following code: :start-after: start-container-save :end-before: end-container-save +.. _mongoid-crud-read-only: + Read-only Documents ------------------- diff --git a/source/interact-data/modify-results.txt b/source/interact-data/modify-results.txt index 70ce8a52..f4a7af78 100644 --- a/source/interact-data/modify-results.txt +++ b/source/interact-data/modify-results.txt @@ -49,13 +49,13 @@ In MongoDB, *projection* is the process of specifying fields to include or exclude from results. {+odm+} provides the following operators to project fields: -- ``only()``: Specifies fields to include -- ``without()``: Specifies fields to exclude +- ``only``: Specifies fields to include +- ``without``: Specifies fields to exclude Include Fields ~~~~~~~~~~~~~~ -The ``only()`` method retrieves only the specified fields from the +The ``only`` method retrieves only the specified fields from the database. The following code returns only the ``name`` field from documents in @@ -75,7 +75,7 @@ which the value of the ``members`` field is ``4``: If you attempt to reference attributes that have not been loaded, {+odm+} raises a ``Mongoid::Errors::AttributeNotLoaded`` error. -You can also use the ``only()`` method to include fields from embedded +You can also use the ``only`` method to include fields from embedded documents. Consider that the ``Band`` model embeds multiple ``Tour`` objects. You can @@ -96,7 +96,7 @@ Then, you can access the embedded fields from the returned documents: # the first Band in the results bands.first.tours.first -You can pass fields of referenced associations to the ``only()`` method, +You can pass fields of referenced associations to the ``only`` method, but the projection is ignored when loading the embedded objects. {+odm+} loads all fields of the referenced associations. For example, when you access the embedded ``Tour`` object as shown in the preceding code, @@ -110,7 +110,7 @@ access the embedded ``Tour`` object as shown in the preceding code, If a document contains ``has_one`` or ``has_and_belongs_to_many`` associations, and you want {+odm+} to load those associations when -you call the ``only()`` method, you must include the fields with foreign +you call the ``only`` method, you must include the fields with foreign keys in the list of attributes. In the following example, the ``Band`` and ``Manager`` models have a @@ -142,7 +142,7 @@ Exclude Fields ~~~~~~~~~~~~~~ You can explicitly exclude fields from results by using the -``without()`` method. +``without`` method. The following code excludes the ``year`` field from returned ``Band`` objects: @@ -157,7 +157,7 @@ objects: {+odm+} requires the ``_id`` field for various operations, so you *cannot* exclude the ``_id`` field or the ``id`` alias from results. - If you pass ``_id`` or ``id`` to the ``without()`` method, {+odm+} + If you pass ``_id`` or ``id`` to the ``without`` method, {+odm+} ignores it. .. _mongoid-data-sort: @@ -166,7 +166,7 @@ Sort Results ------------ You can specify the order in which {+odm+} returns documents by using the -``order()`` and ``order_by()`` methods. +``order`` and ``order_by`` methods. These methods accept a hash that indicates which fields to order the documents by, and whether to use an ascending or descending order for @@ -189,7 +189,7 @@ shows how to sort on the ``name`` and ``year`` fields: - Example: ``Band.order_by(name: "asc", year: "desc")`` -The ``order()`` method also accepts the following sort specifications: +The ``order`` method also accepts the following sort specifications: - Array of two-element arrays: @@ -211,8 +211,8 @@ The ``order()`` method also accepts the following sort specifications: .. tip:: - Instead of using ``order()`` or ``order_by()``, you can also use the - ``asc()`` and ``desc()`` methods to specify sort orders: + Instead of using ``order`` or ``order_by``, you can also use the + ``asc`` and ``desc`` methods to specify sort orders: .. code-block:: ruby @@ -234,14 +234,14 @@ the previous sorts have been applied. Paginate Results ---------------- -{+odm+} provides the ``limit()``, ``skip()``, and ``batch_size()`` +{+odm+} provides the ``limit``, ``skip``, and ``batch_size`` pagination methods that you can use on ``Criteria`` objects. The following sections describe how to use these operators. Limit Number of Results ~~~~~~~~~~~~~~~~~~~~~~~ -You can use the ``limit()`` method to limit the number of results that +You can use the ``limit`` method to limit the number of results that {+odm+} returns. The following code retrieves a maximum of ``5`` documents: @@ -254,7 +254,7 @@ The following code retrieves a maximum of ``5`` documents: .. note:: - Alternatively, you can use the ``take()`` method to retrieve a + Alternatively, you can use the ``take`` method to retrieve a specified number of documents from the database: .. code-block:: ruby @@ -264,10 +264,10 @@ The following code retrieves a maximum of ``5`` documents: Skip Results ~~~~~~~~~~~~ -You can skip a specified number of results by using the ``skip()`` -method, or its alias ``offset()``. +You can skip a specified number of results by using the ``skip`` +method, or its alias ``offset``. -If you chain a ``limit()`` call to ``skip()``, the limit is applied +If you chain a ``limit`` call to ``skip``, the limit is applied after documents are skipped, as demonstrated in the following example: .. literalinclude:: /includes/interact-data/modify-results.rb @@ -278,7 +278,7 @@ after documents are skipped, as demonstrated in the following example: .. tip:: - When performing pagination, use ``skip()`` on :ref:`sorted results ` + When performing pagination, use ``skip`` on :ref:`sorted results ` to ensure consistent results. The following code skips the first ``3`` documents when returning results: @@ -293,10 +293,10 @@ Generate Batches of Results ~~~~~~~~~~~~~~~~~~~~~~~~~~~ When executing large queries and when iterating over query results by using -an enumerator method such as ``Criteria#each()``, {+odm+} automatically +an enumerator method such as ``Criteria#each``, {+odm+} automatically uses the MongoDB :manual:`getMore ` command to load results in batches. The default batch size is ``1000``, but -you can set a different value by using the ``batch_size()`` method. +you can set a different value by using the ``batch_size`` method. The following code sets the batch size to ``500``: @@ -309,4 +309,8 @@ The following code sets the batch size to ``500``: Additional Information ---------------------- -.. TODO: add links to the bottom of this page +To learn more about constructing queries, see the +:ref:`mongoid-data-specify-query` guide. + +To learn about {+odm+} data modeling, see the +:ref:`mongoid-data-modeling` guides. diff --git a/source/interact-data/nested-attributes.txt b/source/interact-data/nested-attributes.txt index fcd10dd9..e7bc673a 100644 --- a/source/interact-data/nested-attributes.txt +++ b/source/interact-data/nested-attributes.txt @@ -81,9 +81,9 @@ There are multiple ways to update a nested attribute: name>_attributes`` in the value to update the associations. - Use the ``update_attributes`` setter method and specify the attribute names in the value to update the associations. -- Use the ``update()`` method and specify ``_attributes`` in the value to update the associations. -- Use the ``create()`` method and specify ``_attributes`` in the value to create the associations. The following example demonstrates how to create a ``Band`` instance @@ -101,7 +101,7 @@ Creating Nested Documents You can create new nested documents by using the nested attributes feature. When creating a document, omit the ``_id`` field. The following -code uses the ``update()`` method to create a nested ``album`` document +code uses the ``update`` method to create a nested ``album`` document on an existing ``Band`` instance: .. literalinclude:: /includes/data-modeling/nested_attr.rb @@ -118,7 +118,7 @@ Updating Nested Documents You can update existing nested documents by using the nested attributes feature. To instruct {+odm+} to update a nested document by using -attributes, pass the document's ``_id`` value to the ``update()`` +attributes, pass the document's ``_id`` value to the ``update`` method. The following example uses the ``_id`` value of an ``albums`` entry to update the ``year`` field: @@ -137,7 +137,7 @@ Delete Nested Documents ----------------------- You can delete nested documents by specifying the ``_destroy`` -attribute to the ``update()`` method. To enable deletion of nested +attribute to the ``update`` method. To enable deletion of nested document, you must set ``allow_destroy: true`` in the ``accepts_nested_attributes_for`` declaration, as shown in the following code: @@ -187,6 +187,8 @@ Additional Information To learn more about querying, see the :ref:`mongoid-data-specify-query` guide. -.. TODO link to CRUD guide +To learn more about performing CRUD operations, see the +:ref:`mongoid-data-crud` guide. -.. TODO link to associations guide +To learn more about associations, see the :ref:`mongoid-associations` +guide. diff --git a/source/interact-data/query-async.txt b/source/interact-data/query-async.txt index 166b24b4..0891b599 100644 --- a/source/interact-data/query-async.txt +++ b/source/interact-data/query-async.txt @@ -87,6 +87,8 @@ configuration options: Additional Information ---------------------- -.. TODO link to config guide +To learn more about configuring {+odm+} in your application, see the +:ref:`mongoid-app-config` guide. -.. TODO link to crud operations \ No newline at end of file +To learn more about performing CRUD operations, see the +:ref:`mongoid-data-crud` guide. diff --git a/source/interact-data/query-cache.txt b/source/interact-data/query-cache.txt index 2b477dee..d1cefd31 100644 --- a/source/interact-data/query-cache.txt +++ b/source/interact-data/query-cache.txt @@ -42,8 +42,8 @@ Automatic The {+ruby-driver+} provides middleware to automatically enable the query cache for Rack web requests and Active Job job runs. To view instructions on automatically enabling the query cache, see the -:ref:`Query Cache Rack Middleware ` section of -the configuration guide. +:ref:`mongoid-query-cache-rack` section of the Query Cache Middleware +Configuration guide. .. note:: diff --git a/source/interact-data/query-persistence.txt b/source/interact-data/query-persistence.txt index c6a42f77..2578f7a2 100644 --- a/source/interact-data/query-persistence.txt +++ b/source/interact-data/query-persistence.txt @@ -28,7 +28,8 @@ insert, update, and delete operations. To learn more about creating filter criteria, see the :ref:`mongoid-data-specify-query` guide. -.. TODO To learn more about performing CRUD operations, see the :ref:`` guide. +To learn more about performing CRUD operations, see the +:ref:`mongoid-data-crud` guide. Persistence Methods ------------------- diff --git a/source/interact-data/scoping.txt b/source/interact-data/scoping.txt index 49329818..b16c1fb6 100644 --- a/source/interact-data/scoping.txt +++ b/source/interact-data/scoping.txt @@ -101,7 +101,8 @@ You can direct {+odm+} to raise an error when a scope overwrites an existing class method by setting the ``scope_overwrite_exception`` configuration option to ``true``. -.. TODO add link to config options page +To learn more about this setting, see the :ref:`mongoid-app-config` +guide. Default Scopes -------------- @@ -111,10 +112,10 @@ criteria to most queries. By defining a default scope, you specify these criteria as the default for any queries that use the model. Default scopes return ``Criteria`` objects. -To create a default scope, you must define the ``default_scope()`` method +To create a default scope, you must define the ``default_scope`` method on your model class. -The following code defines the ``default_scope()`` method on the ``Band`` +The following code defines the ``default_scope`` method on the ``Band`` model to only retrieve documents in which the ``active`` field value is ``true``: .. literalinclude:: /includes/interact-data/scoping.rb @@ -179,7 +180,7 @@ Suppose you create a ``Label`` model that contains an association to a ``Band`` in which the value of ``active`` is ``true``. When you update the ``active`` field to ``false``, {+odm+} still loads it despite the default scope. To view the documents in the association with the scope -applied, you must call the ``reload()`` operator. +applied, you must call the ``reload`` operator. The following code demonstrates this sequence: @@ -195,7 +196,7 @@ or and nor Query Behavior {+odm+} treats the criteria in a default scope the same way as any other query conditions. This can lead to surprising behavior when using the -``or()`` and ``nor()`` methods. +``or`` and ``nor`` methods. The following examples demonstrate how {+odm+} interprets queries on models with a default scope: @@ -224,7 +225,7 @@ You can direct {+odm+} to not apply the default scope by using the Override Default Scope at Runtime --------------------------------- -You can use the ``with_scope()`` method to change the default scope in a +You can use the ``with_scope`` method to change the default scope in a block at runtime. The following model defines the *named* scope ``mexican``: @@ -236,7 +237,7 @@ The following model defines the *named* scope ``mexican``: :dedent: :emphasize-lines: 7 -You can use the ``with_scope()`` method to set the ``mexican`` named +You can use the ``with_scope`` method to set the ``mexican`` named scope as the default scope at runtime, as shown in the following code: .. literalinclude:: /includes/interact-data/scoping.rb @@ -262,4 +263,5 @@ the following example: Additional Information ---------------------- -.. TODO add info links \ No newline at end of file +To learn more about customizing your {+odm+} models, see the +:ref:`mongoid-data-modeling` guides. diff --git a/source/interact-data/specify-query.txt b/source/interact-data/specify-query.txt index 6e70e805..6b77b622 100644 --- a/source/interact-data/specify-query.txt +++ b/source/interact-data/specify-query.txt @@ -75,10 +75,10 @@ following example demonstrates the return type for a simple query: # Returns matching documents # => [{"_id":"...","name":"Deftones"}] -You can use methods such as ``first()`` and ``last()`` to return +You can use methods such as ``first`` and ``last`` to return individual documents. You can also iterate a ``Criteria`` object by using -methods such as ``each()`` or ``map()`` to retrieve documents from the -server. You can use ``to_json()`` to convert a ``Criteria`` object to +methods such as ``each`` or ``map`` to retrieve documents from the +server. You can use ``to_json`` to convert a ``Criteria`` object to JSON. .. tip:: Chaining methods @@ -175,8 +175,6 @@ types of values. Defined Fields ~~~~~~~~~~~~~~ -.. TODO add link to Fields page - To query on a field, the field does not need to be in the the model class definition. However, if a field is defined in the model class, {+odm+} coerces query values to match the defined field @@ -193,6 +191,9 @@ to ``2020`` when performing the query: :language: ruby :dedent: +To learn more about defining fields in {+odm+}, see the +:ref:`mongoid-field-types` guide. + Raw Values ~~~~~~~~~~ @@ -211,10 +212,9 @@ the ``Mongoid::RawValue`` class, as shown in the following code: Field Aliases ~~~~~~~~~~~~~ -.. TODO update links - -Queries follow the :ref:`storage field names ` -and :ref:`field aliases ` that you might have set in your +Queries follow the :ref:`storage field +names ` and :ref:`field aliases +` that you might have set in your model class definition. The ``id`` and ``_id`` fields are aliases, so you can use either field @@ -261,13 +261,13 @@ Logical Operations {+odm+} supports the following logical operations on ``Criteria`` objects: -- ``and()`` -- ``or()`` -- ``nor()`` -- ``not()`` +- ``and`` +- ``or`` +- ``nor`` +- ``not`` These methods take one or more hashes of conditions or another -``Criteria`` object as their arguments. The ``not()`` operation has an +``Criteria`` object as their arguments. The ``not`` operation has an argument-free version. The following code demonstrates how to use the logical operations in @@ -312,10 +312,10 @@ following code: :language: ruby :dedent: -The ``any_of()``, ``none_of()``, ``nor()``, and ``not()`` operations +The ``any_of``, ``none_of``, ``nor``, and ``not`` operations behave similarly. -When you use ``and()``, ``or()``, and ``nor()`` logical operators, they +When you use ``and``, ``or``, and ``nor`` logical operators, they operate on the criteria built up to that point: .. literalinclude:: /includes/interact-data/query.rb @@ -324,15 +324,15 @@ operate on the criteria built up to that point: :language: ruby :dedent: -not() Behavior -~~~~~~~~~~~~~~ +not Behavior +~~~~~~~~~~~~ -You can use the ``not()`` method without arguments, in which case it -negates the next condition that is specified. The ``not()`` method can +You can use the ``not`` method without arguments, in which case it +negates the next condition that is specified. The ``not`` method can be called with one or more hash conditions or ``Criteria`` objects, which are all negated and added to the criteria. -The following examples demonstrate the behavior of ``not()``: +The following examples demonstrate the behavior of ``not``: .. literalinclude:: /includes/interact-data/query.rb :start-after: start-not-logical @@ -351,7 +351,7 @@ The following examples demonstrate the behavior of ``not()``: :language: ruby :dedent: -Similarly to ``and()``, the ``not()`` operation negates individual +Similarly to ``and``, the ``not`` operation negates individual conditions for simple field criteria. For complex conditions and when a field already has a condition defined on it, {+odm+} emulates ``$not`` by using an ``{'$and' => [{'$nor' => ...}]}`` construct, because MongoDB @@ -364,7 +364,7 @@ globally: :language: ruby :dedent: -If you are using ``not()`` with arrays or regular expressions, view the +If you are using ``not`` with arrays or regular expressions, view the limitations of ``$not`` in the :manual:`{+server-manual+} `. @@ -373,7 +373,7 @@ Incremental Query Construction By default, when you add conditions to a query, {+odm+} considers each condition complete and independent from any other conditions -present in the query. For example, calling ``in()`` twice adds two separate +present in the query. For example, calling ``in`` twice adds two separate ``$in`` conditions: .. literalinclude:: /includes/interact-data/query.rb @@ -408,7 +408,7 @@ Merge Strategies operator value. The following code demonstrates how the merge strategies produce -criteria by using ``in()`` as the example operator: +criteria by using ``in`` as the example operator: .. literalinclude:: /includes/interact-data/query.rb :start-after: start-in-merge @@ -416,7 +416,7 @@ criteria by using ``in()`` as the example operator: :language: ruby :dedent: -The strategy is requested by calling ``override()``, ``intersect()`` or ``union()`` +The strategy is requested by calling ``override``, ``intersect`` or ``union`` on a ``Criteria`` instance. The requested strategy applies to the next condition method called on the query. If the next condition method called does not support merge strategies, the strategy is reset, as shown in the following @@ -428,8 +428,8 @@ example: :language: ruby :dedent: -Because ``ne()`` does not support merge strategies, the ``union`` strategy -is ignored and reset. Then, when ``in()`` is invoked the second time, +Because ``ne`` does not support merge strategies, the ``union`` strategy +is ignored and reset. Then, when ``in`` is invoked the second time, there is no active strategy. .. warning:: @@ -444,9 +444,9 @@ Supported Operator Methods The following operator methods support merge strategies: -- ``all()`` -- ``in()`` -- ``nin()`` +- ``all`` +- ``in`` +- ``nin`` The set of methods might be expanded in future releases of {+odm+}. To ensure future compatibility, invoke a strategy method only when the next method call @@ -455,7 +455,7 @@ is an operator that supports merge strategies. Merge strategies are applied only when conditions are added through the designated methods. In the following example, the merge strategy is not applied because the second condition is added as -``where()``, not by using ``in()``: +``where``, not by using ``in``: .. literalinclude:: /includes/interact-data/query.rb :start-after: start-merge-where @@ -471,7 +471,7 @@ value type. {+odm+} expands ``Array``-compatible types, such as a ``Range``, when they are used with these operator methods. The following example demonstrates how you can pass a ``Range`` object -as the query value when using the ``in()`` method: +as the query value when using the ``in`` method: .. literalinclude:: /includes/interact-data/query.rb :start-after: start-range-query @@ -490,12 +490,12 @@ as the shown in the following example: Element Match ------------- -You can use the ``elem_match()`` method to match documents that contain +You can use the ``elem_match`` method to match documents that contain an array field with at least one element that matches all the specified query criteria. The following example creates a sample document that contains an array -field. Then, it uses the ``elem_match()`` method to match documents in +field. Then, it uses the ``elem_match`` method to match documents in which the ``tour`` array field contains an entry in which the ``city`` value is ``'London'``: @@ -508,7 +508,7 @@ value is ``'London'``: Associations ~~~~~~~~~~~~ -You can use the ``elem_match()`` method to match embedded associations. +You can use the ``elem_match`` method to match embedded associations. This example uses the following models that define an embedded association between ``Band`` and ``Tour``: @@ -520,7 +520,7 @@ association between ``Band`` and ``Tour``: :dedent: The following code creates a ``Band`` object and embedded ``Tour`` -objects, then uses the ``elem_match()`` method to query on the ``city`` +objects, then uses the ``elem_match`` method to query on the ``city`` field: .. literalinclude:: /includes/interact-data/query.rb @@ -531,13 +531,13 @@ field: .. note:: - You cannot use ``elem_match()`` on non-embedded associations because + You cannot use ``elem_match`` on non-embedded associations because MongoDB does not perform a join operation on the collections. If you perform this query, the conditions are added to the collection that is the source of the non-embedded association rather than the collection of the association. -You can use ``elem_match()`` to query recursively embedded associations, +You can use ``elem_match`` to query recursively embedded associations, as shown in the following example: .. literalinclude:: /includes/interact-data/query.rb @@ -546,13 +546,16 @@ as shown in the following example: :language: ruby :dedent: +To learn more about associations, see the :ref:`mongoid-associations` +guide. + Querying by _id Value --------------------- -{+odm+} provides the ``find()`` method, which allows you to query +{+odm+} provides the ``find`` method, which allows you to query documents by their ``_id`` values. -The following example uses the ``find()`` method to match a document +The following example uses the ``find`` method to match a document with the specified ``_id`` field value: .. code-block:: ruby @@ -561,22 +564,22 @@ with the specified ``_id`` field value: .. note:: Type Conversion - When you pass an ID value to the ``find()`` method, the method + When you pass an ID value to the ``find`` method, the method converts it to the data type declared for the ``_id`` field in the model. By default, the ``_id`` field is defined as a ``BSON::ObjectId`` type. The preceding example is equivalent to the following code, which - passes an ``BSON::ObjectId`` instance as the argument to ``find()``: + passes an ``BSON::ObjectId`` instance as the argument to ``find``: .. code-block:: ruby Band.find(BSON::ObjectId.from_string('5f0e41d92c97a64a26aabd10')) If you use the {+ruby-driver+} to query on the ``_id`` field, - ``find()`` does not internally perform the type conversion. + ``find`` does not internally perform the type conversion. -The ``find()`` method accepts multiple arguments, or an array of arguments. +The ``find`` method accepts multiple arguments, or an array of arguments. {+odm+} interprets each argument or array element as an ``_id`` value, and returns documents with all the specified ``_id`` values in an array, as shown in the following example: @@ -587,7 +590,7 @@ values in an array, as shown in the following example: :language: ruby :dedent: -The ``find()`` method exhibits the following behavior: +The ``find`` method exhibits the following behavior: - If you provide the same ``_id`` value more than once, {+odm+} returns only one document, if one exists. @@ -601,27 +604,27 @@ The ``find()`` method exhibits the following behavior: option. If you set the ``raise_not_found_error`` option to ``true``, - ``find()`` raises a ``Mongoid::Errors::DocumentNotFound`` error if any + ``find`` raises a ``Mongoid::Errors::DocumentNotFound`` error if any of the ``_id`` values are not found. If you set the ``raise_not_found_error`` option to ``false`` and query - for a single ``_id`` value, ``find()`` returns ``nil`` if {+odm+} does + for a single ``_id`` value, ``find`` returns ``nil`` if {+odm+} does not match a document. If you pass multiple ``_id`` values and some or all are not matched, the return value is an array of any documents that match, or an empty array if no documents match. -find() Variations ------------------ +find Variations +--------------- -This section describes methods that are similar to the ``find()`` method +This section describes methods that are similar to the ``find`` method described in the preceding section. -You can use the ``find_by()`` method to retrieve documents based on the +You can use the ``find_by`` method to retrieve documents based on the provided criteria. If no documents are found, it raises an error or returns ``nil`` depending on how you set the ``raise_not_found_error`` configuration option. -The following code demonstrates how to use the ``find_by()`` method: +The following code demonstrates how to use the ``find_by`` method: .. literalinclude:: /includes/interact-data/query.rb :start-after: start-query-findby @@ -629,11 +632,11 @@ The following code demonstrates how to use the ``find_by()`` method: :language: ruby :dedent: -You can use the ``find_or_create_by()`` method to retrieve documents +You can use the ``find_or_create_by`` method to retrieve documents based on the provided criteria. If no documents are found, it creates and returns an instance that is saved to MongoDB. -The following code demonstrates how to use the ``find_or_create_by()`` +The following code demonstrates how to use the ``find_or_create_by`` method: .. literalinclude:: /includes/interact-data/query.rb @@ -642,12 +645,14 @@ method: :language: ruby :dedent: -You can use the ``find_or_initialize_by()`` method to retrieve documents +You can use the ``find_or_initialize_by`` method to retrieve documents based on the provided criteria. If no documents are found, it returns a new one, without persisting it to MongoDB. Use the same syntax for -``find_or_initialize_by()`` as you do for the ``find_or_create_by()`` +``find_or_initialize_by`` as you do for the ``find_or_create_by`` method. +.. _mongoid-query-regex: + Regular Expressions ------------------- @@ -678,6 +683,8 @@ You can also perform queries by using Perl Compatible Regular Expression :language: ruby :dedent: +.. _mongoid-query-field-type-conversions: + Field Type Query Conversions ---------------------------- @@ -717,11 +724,10 @@ behavior, as shown in the following example: In the preceding example, the following conversions apply: -.. TODO add link to time zone configuration - - When using a ``Date`` value to query the ``Time``-valued ``last_commented`` field, {+odm+} interprets the date to be in local - time and applies the :ref:`configured time zone <>`. + time and applies the :ref:`configured time zone + `. - When querying on the ``last_purchased`` field, which has no explicit type, the date is used unmodified in the constructed query. @@ -739,11 +745,11 @@ This section describes more query methods that you can use in {+odm+}. Count Documents ~~~~~~~~~~~~~~~ -You can use the ``count()`` and ``estimated_count()`` methods to count +You can use the ``count`` and ``estimated_count`` methods to count the number of documents in a collection. You can count the number of documents that match filter criteria by -using the ``count()`` method: +using the ``count`` method: .. code-block:: ruby @@ -753,23 +759,23 @@ using the ``count()`` method: # Counts documents that match criteria Band.where(country: 'England').count -.. tip:: length() and size() Methods +.. tip:: length and size Methods - You can also use the ``length()`` or ``size()`` method to count documents. + You can also use the ``length`` or ``size`` method to count documents. These methods cache subsequent calls to the database, which might produce performance improvements. You can get an approximate number of documents in the collection from -the collection metadata by using the ``estimated_count()`` method: +the collection metadata by using the ``estimated_count`` method: .. code-block:: ruby Band.estimated_count -The ``estimated_count()`` method does not accept query conditions, +The ``estimated_count`` method does not accept query conditions, including conditions set by a :ref:`scope ` on the model. If you are calling this method on a model that has a -default scope, you must first call the ``unscoped()`` method to +default scope, you must first call the ``unscoped`` method to disable the scope. Ordinal Methods @@ -778,39 +784,39 @@ Ordinal Methods The methods described in the following list allow you to select a specific result from the list of returned documents based on its position. -- ``first()``: Returns the first matching document. You can get the +- ``first``: Returns the first matching document. You can get the first ``n`` documents by passing an integer-valued parameter. This method automatically uses a sort on the ``_id`` field. *See lines 1-8 in the following code for examples.* -- ``last()``: Returns the last matching document. You can get the +- ``last``: Returns the last matching document. You can get the last ``n`` documents by passing an integer-valued parameter. This method automatically uses a sort on the ``_id`` field. *See line 11 in the following code for an example.* -- ``first_or_create()``: Returns the first matching document. If no +- ``first_or_create``: Returns the first matching document. If no document matches, creates and returns a newly saved one. -- ``first_or_initialize()``: Returns the first matching document. If no +- ``first_or_initialize``: Returns the first matching document. If no document matches, returns a new one. -- ``second()``: Returns the second matching document. Automatically uses +- ``second``: Returns the second matching document. Automatically uses a sort on the ``_id`` field. -- ``third()``: Returns the third matching document. Automatically uses +- ``third``: Returns the third matching document. Automatically uses a sort on the ``_id`` field. -- ``fourth()``: Returns the fourth matching document. Automatically uses +- ``fourth``: Returns the fourth matching document. Automatically uses a sort on the ``_id`` field. -- ``fifth()``: Returns the fifth matching document. Automatically uses +- ``fifth``: Returns the fifth matching document. Automatically uses a sort on the ``_id`` field. -- ``second_to_last()``: Returns the second-to-last matching document. +- ``second_to_last``: Returns the second-to-last matching document. Automatically uses a sort on the ``_id`` field. *See line 14 in the following code for an example.* -- ``third_to_last()``: Returns the third-to-last matching document. +- ``third_to_last``: Returns the third-to-last matching document. Automatically uses a sort on the ``_id`` field. The following code demonstrates how to use some methods described @@ -828,8 +834,8 @@ in the preceding list: Each method described in this section has a variation that is suffixed with ``!`` that returns an error if {+odm+} doesn't match any documents. For example, to implement error handling in your - application when your query returns no results, use the ``first!()`` - method instead of ``first()``. + application when your query returns no results, use the ``first!`` + method instead of ``first``. Survey Field Values ~~~~~~~~~~~~~~~~~~~ @@ -837,24 +843,25 @@ Survey Field Values To inspect the values of specified fields of documents in a collection, you can use the following methods: -- ``distinct()``: Gets a list of distinct values for a single field. +- ``distinct``: Gets a list of distinct values for a single field. *See lines 1-7 in the following code for examples.* -- ``pick()``: Gets the values from one document for the provided fields. +- ``pick``: Gets the values from one document for the provided fields. Returns ``nil`` for unset fields and for non-existent fields. *See line 10 in the following code for an example.* -- ``pluck()``: Gets all values for the provided field. Returns ``nil`` +- ``pluck``: Gets all values for the provided field. Returns ``nil`` for unset fields and for non-existent fields. *See line 13 in the following code for an example.* -- ``tally()``: Gets a mapping of values to counts for the specified +- ``tally``: Gets a mapping of values to counts for the specified field. *See line 16 in the following code for an example.* The preceding methods accept field names referenced by using dot notation, which allows you to reference fields in embedded associations. -They also respect :ref:`field aliases `, including -those defined in embedded documents. +They also respect :ref:`field aliases +`, including those defined in embedded +documents. The following code demonstrates how to use these methods: @@ -871,7 +878,7 @@ Miscellaneous The following list describes {+odm+} methods that do not fit into another category: -- ``each()``: Iterates over all matching documents. +- ``each``: Iterates over all matching documents. .. code-block:: ruby @@ -880,7 +887,7 @@ category: p band.name end -- ``exists?()``: Determines if any matching documents exist, returning +- ``exists?``: Determines if any matching documents exist, returning ``true`` if at least one matching document is found. .. code-block:: ruby diff --git a/source/interact-data/text-search.txt b/source/interact-data/text-search.txt index a777bf0d..c39e90c1 100644 --- a/source/interact-data/text-search.txt +++ b/source/interact-data/text-search.txt @@ -49,8 +49,6 @@ The following sections describe how to perform each of these actions. Define a Text Index on Your Model --------------------------------- -.. TODO link to indexes page - Use the ``index`` macro to specify the text index in your model definition. The following code creates a ``Dish`` model class that includes a text index on the ``description`` field: @@ -80,6 +78,9 @@ Rake task to create the index based on your model specification: bundle exec rake db:mongoid:create_indexes +To learn more about using indexes with {+odm+}, see the +:ref:`mongoid-indexes` guide. + Perform Text Searches --------------------- @@ -210,4 +211,5 @@ Additional Information To learn more about constructing query filters, see :ref:`mongoid-data-specify-query`. -.. TODO link to CRUD guide +To learn more about performing CRUD operations, see the +:ref:`mongoid-data-crud` guide. diff --git a/source/interact-data/transaction.txt b/source/interact-data/transaction.txt index 04cef370..71ec9ae2 100644 --- a/source/interact-data/transaction.txt +++ b/source/interact-data/transaction.txt @@ -60,10 +60,10 @@ You can use the High-Level Transaction API to internally manage the lifecycle of your transaction. This API either commits your transaction or ends it and incorporates error handling logic. -You can start a transaction by calling the ``transaction()`` method on +You can start a transaction by calling the ``transaction`` method on an instance of a model, on the model class, or on a ``{+odm+}`` module. -When you call the ``transaction()`` method, {+odm+} performs the +When you call the ``transaction`` method, {+odm+} performs the following tasks: 1. Creates a session on the client. @@ -124,7 +124,7 @@ and demonstrates how operations are run based on the origin client: .. note:: - When you call the ``transaction()`` method on the ``{+odm+}`` module, + When you call the ``transaction`` method on the ``{+odm+}`` module, {+odm+} creates the transaction by using the ``:default`` client. Ending Transactions @@ -168,7 +168,8 @@ created, saved, or deleted inside a transaction, if the transaction was unsuccessful and changes were rolled back. {+odm+} never triggers ``after_rollback`` outside of a transaction. -.. TODO link to callbacks guide. +To learn more about callbacks, see the :ref:`mongoid-modeling-callbacks` +guide. .. _mongoid-txn-low-level: @@ -177,12 +178,12 @@ Low-Level Transaction API When using the low-level API, you must create a session before starting a transaction. You can create a session by calling the -``with_session()`` method on a model class or an instance of a model. +``with_session`` method on a model class or an instance of a model. -Then, you can start a transaction by calling the ``start_transaction()`` +Then, you can start a transaction by calling the ``start_transaction`` method on a session. When using this API, you must manually commit or -end the transaction. You can use the ``commit_transaction()`` and -``abort_transaction()`` methods on the session instance to manage the +end the transaction. You can use the ``commit_transaction`` and +``abort_transaction`` methods on the session instance to manage the transaction lifecycle. Example @@ -225,7 +226,7 @@ Options You can specify a read concern, write concern or read preference when starting a transaction by passing options to the -``start_transaction()`` method: +``start_transaction`` method: .. code-block:: ruby @@ -236,7 +237,7 @@ preference when starting a transaction by passing options to the ) To learn more about the available transaction options, see -:ruby-api:`start_transaction() +:ruby-api:`start_transaction ` in the {+ruby-driver+} API documentation. @@ -247,7 +248,7 @@ To perform operations within a transaction, operations must use the same client that the session was initiated on. By default, all operations are performed by using the default client. -To explicitly use a different client, use the ``with()`` method: +To explicitly use a different client, use the ``with`` method: .. literalinclude:: /includes/interact-data/transaction.rb :start-after: start-other-client @@ -261,7 +262,7 @@ Session API ----------- You can use sessions in {+odm+} in a similar way that you can -perform a transaction. You can call the ``with_session()`` method on a +perform a transaction. You can call the ``with_session`` method on a model class or on an instance of a model and perform some operations in a block. All operations in the block will be performed in the context of single session. @@ -270,9 +271,9 @@ The following limitations apply when using sessions: - You cannot share a session across threads. Sessions are not thread-safe. -- You cannot nest sessions. For example, you cannot call the ``with_session()`` +- You cannot nest sessions. For example, you cannot call the ``with_session`` method on a model class within the block passed to - the ``with_session()`` method on another model class. The following + the ``with_session`` method on another model class. The following code demonstrates a nested session that results in an error: .. code-block:: ruby @@ -287,13 +288,13 @@ The following limitations apply when using sessions: - All model classes and instances used within the session block must use the same driver client. For example, if you specify different a different client for a model used in the block than those of the - model or instance that you called ``with_session()`` on, {+odm+} returns + model or instance that you called ``with_session`` on, {+odm+} returns an error. Examples ~~~~~~~~ -You can use the ``with_session()`` method on a model class and pass it session +You can use the ``with_session`` method on a model class and pass it session options to perform a block of operations in the context of a session. The following code enables the ``causal_consistency`` option to @@ -311,7 +312,7 @@ To learn more about the available session options, see the ` in the {+ruby-driver+} API documentation. -Alternatively, you can use the ``with_session()`` method on an instance of a +Alternatively, you can use the ``with_session`` method on an instance of a model and pass it session options to perform a block of operations in the context of a session. @@ -331,4 +332,5 @@ Additional Information To learn more about transactions, see :manual:`Transactions ` in the {+server-manual+}. -.. TODO To learn more about performing CRUD operations, see the :ref:`` guide. +To learn more about performing CRUD operations, see the +:ref:`mongoid-data-crud` guide. diff --git a/source/legacy-files/upgrading.txt b/source/legacy-files/upgrading.txt index 3b5b39bc..ef6bdd3b 100644 --- a/source/legacy-files/upgrading.txt +++ b/source/legacy-files/upgrading.txt @@ -51,7 +51,7 @@ Before you Upgrade - *Test Coverage:* The best way to be sure that your application still works after upgrading is to have good test coverage before you start the process. -- *Upgrade Ruby and Rails:* See `"Upgrading {+ror+}" `_ +- *Upgrade Ruby and Rails:* See `"Upgrading {+ror+}" <{+active-record-docs+}/upgrading_ruby_on_rails.html>`_ for more information diff --git a/source/quick-start-rails.txt b/source/quick-start-rails.txt index f2db9fd5..17fb1571 100644 --- a/source/quick-start-rails.txt +++ b/source/quick-start-rails.txt @@ -35,7 +35,7 @@ To learn how to integrate {+odm+} into an existing application, see the `. {+odm+} is an Object-Document Mapper (ODM) framework for MongoDB in -Ruby. By using {+odm+}, you can easily interact with your data and +{+language+}. By using {+odm+}, you can easily interact with your data and create flexible data models. {+ror+} is a web application framework for @@ -56,9 +56,6 @@ Follow the steps in this guide to create a sample {+odm+} web application that connects to a MongoDB deployment. .. tip:: Other Framework Tutorials - - If you prefer to use Rails 6 to build your application, see the - :ref:`mongoid-getting-started-rails-6` guide. If you prefer to use Sinatra as your web framework, see the :ref:`mongoid-quick-start-sinatra` guide. diff --git a/source/quick-start-rails/download-and-install.txt b/source/quick-start-rails/download-and-install.txt index cf7ae849..009325dd 100644 --- a/source/quick-start-rails/download-and-install.txt +++ b/source/quick-start-rails/download-and-install.txt @@ -17,10 +17,10 @@ Prerequisites To create the Quick Start application by using {+ror+} 8, you need the following software installed in your development environment: -- `{+language+}. `__ +- `{+language+} language. `__ Rails requires {+language+} v3.1.0 or later. Use the latest version to prevent version conflicts. -- `RubyGems package manager. `__ +- :rubygems:`RubyGems package manager. ` - A terminal app and shell. For MacOS users, use Terminal or a similar app. For Windows users, use PowerShell. diff --git a/source/quick-start-rails/next-steps.txt b/source/quick-start-rails/next-steps.txt index 1869ddf1..aadc3e60 100644 --- a/source/quick-start-rails/next-steps.txt +++ b/source/quick-start-rails/next-steps.txt @@ -21,11 +21,10 @@ the sample data, and render retrieved results. .. `mongoid-quickstart <>`__ .. GitHub repository. -.. TODO Learn more about {+odm+} features from the following resources: +Learn more about {+odm+} features from the following sections: -.. - :ref:`mongoid-fundamentals-connection`: Learn how to configure your MongoDB -.. connection. -.. -.. - :ref:`mongoid-usage-examples`: See code examples of frequently used MongoDB -.. operations. +- :ref:`mongoid-data-modeling`: Learn how to customize your {+odm+} + models. +- :ref:`mongoid-interact-data`: Learn how to interact with your MongoDB + data by using {+odm+} models. diff --git a/source/quick-start-rails/view-data.txt b/source/quick-start-rails/view-data.txt index 81f1355c..3e06b140 100644 --- a/source/quick-start-rails/view-data.txt +++ b/source/quick-start-rails/view-data.txt @@ -32,7 +32,7 @@ View MongoDB Data The ``app/controllers/restaurants_controller.rb`` file contains methods that specify how your app handles different - requests. Replace the ``index()`` method body with the following code: + requests. Replace the ``index`` method body with the following code: .. code-block:: ruby diff --git a/source/quick-start-sinatra.txt b/source/quick-start-sinatra.txt index a5fb7bc7..d9d88d84 100644 --- a/source/quick-start-sinatra.txt +++ b/source/quick-start-sinatra.txt @@ -34,7 +34,7 @@ To learn how to integrate {+odm+} into an existing application, see the `. {+odm+} is an Object-Document Mapper (ODM) framework for MongoDB in -Ruby. By using {+odm+}, you can easily interact with your data and +{+language+}. By using {+odm+}, you can easily interact with your data and create flexible data models. Sinatra is a domain-specific language (DSL) for creating web diff --git a/source/quick-start-sinatra/download-and-install.txt b/source/quick-start-sinatra/download-and-install.txt index b0a92bbf..fa762905 100644 --- a/source/quick-start-sinatra/download-and-install.txt +++ b/source/quick-start-sinatra/download-and-install.txt @@ -17,8 +17,8 @@ Prerequisites To create the Quick Start application by using Sinatra, you need the following software installed in your development environment: -- `{+language+}. `__ -- `RubyGems package manager. `__ +- `{+language+} language. `__ +- :rubygems:`RubyGems package manager. ` - A terminal app and shell. For MacOS users, use Terminal or a similar app. For Windows users, use PowerShell. diff --git a/source/quick-start-sinatra/next-steps.txt b/source/quick-start-sinatra/next-steps.txt index d2c03d89..f27b0c2f 100644 --- a/source/quick-start-sinatra/next-steps.txt +++ b/source/quick-start-sinatra/next-steps.txt @@ -21,11 +21,10 @@ the sample data, and render retrieved results. .. `mongoid-quickstart <>`__ .. GitHub repository. -.. TODO Learn more about {+odm+} features from the following resources: +Learn more about {+odm+} features from the following sections: -.. - :ref:`mongoid-fundamentals-connection`: Learn how to configure your MongoDB -.. connection. -.. -.. - :ref:`mongoid-usage-examples`: See code examples of frequently used MongoDB -.. operations. +- :ref:`mongoid-data-modeling`: Learn how to customize your {+odm+} + models. +- :ref:`mongoid-interact-data`: Learn how to interact with your MongoDB + data by using {+odm+} models. diff --git a/source/quick-start-sinatra/view-data.txt b/source/quick-start-sinatra/view-data.txt index 00171ffc..3925552a 100644 --- a/source/quick-start-sinatra/view-data.txt +++ b/source/quick-start-sinatra/view-data.txt @@ -103,7 +103,7 @@ View MongoDB Data .. step:: (Optional) View your results as JSON documents Instead of generating a view to render your results, you can - use the ``to_json()`` method to display your results in JSON + use the ``to_json`` method to display your results in JSON format. Replace the ``list_restaurants`` route in the ``app.rb`` file with diff --git a/source/security/encryption.txt b/source/security/encryption.txt index 904affc0..641bf12a 100644 --- a/source/security/encryption.txt +++ b/source/security/encryption.txt @@ -110,7 +110,7 @@ mongocryptd (Driver v2.18 or earlier) If you are using {+ruby-driver+} version 2.18 or earlier, you must use ``mongocryptd`` instead of the {+shared-library+}. ``mongocryptd`` comes -pre-packaged with enterprise builds of MongoDB Server. For instructions on how to +pre-packaged with enterprise builds of {+mdb-server+}. For instructions on how to install and configure ``mongocryptd``, see the :manual:`Install mongocryptd guide ` in the MongoDB {+server-manual+}. @@ -118,7 +118,7 @@ install and configure ``mongocryptd``, see the :manual:`Install mongocryptd guid ffi ~~~ -{+odm+} uses the `ffi gem `__ to call functions from +{+odm+} uses the :github:`ffi gem ` to call functions from ``libmongocrypt``. Add the gem to your ``Gemfile`` by running the following command in your shell: @@ -330,4 +330,5 @@ To learn more about using CSFLE with the {+ruby-driver+}, see the ` guide in the {+ruby-driver+} documentation. -.. TODO: Add link to mongoid configuration page for encryption settings when available. \ No newline at end of file +To learn more about configuring {+odm+} in your application, see the +:ref:`mongoid-app-config` guide.