diff --git a/config/redirects b/config/redirects index 2ac0239a257..6fe4a9ac1c9 100644 --- a/config/redirects +++ b/config/redirects @@ -1522,7 +1522,7 @@ raw: /master/release-notes/3.0-general-improvements -> ${base}/release-notes/3.0 [*-v3.4]: /${version}/reference/operator/aggregation/currentOp -> ${base}/${version}/reference/command/currentOp/ # 2.8 compatibility -# + # [*]: /${version}/release-notes/2.8-downgrade -> ${base}/${version}/release-notes/ # [*]: /${version}/release-notes/2.8-compatibility -> ${base}/${version}/release-notes/ # [*]: /${version}/release-notes/2.8-changes -> ${base}/${version}/release-notes/ @@ -1799,9 +1799,14 @@ raw: /manual/core/wildcard -> ${base}/manual/core/index-wildcard/ [v5.0-*]: /${version}/reference/command/isMaster -> ${base}/${version}/reference/command/hello/ [v5.0-*]: /${version}/reference/method/db.isMaster -> ${base}/${version}/reference/method/db.hello/ +[v5.0-*]: /${version}/reference/method/db.collection.copyTo.txt -> ${base}/${version}/reference/operator/aggregation/out/ +[v5.0-*]: /${version}/reference/method/db.collection.save.txt -> ${base}/${version}/reference/method/db.collection.insertOne/ [v5.0-*]: /${version}/reference/method/db.eval -> ${base}/${version}/reference/method/js-database/ [v5.0-*]: /${version}/reference/method/db.getProfilingLevel -> ${base}/${version}/reference/method/db.getProfilingStatus/ -[v5.0-*]: /${version}/reference/method/Mongo.isCausalConsistency -> ${base}/${version}/core/crud/ +[v5.0-*]: /${version}/reference/method/Mongo.getSecondaryOk -> ${base}/${version}/reference/method/Mongo.getReadPrefMode/ +[v5.0-*]: /${version}/reference/method/Mongo.isCausalConsistency -> ${base}/${version}/core/causal-consistency-read-write-concerns/ +[v5.0-*]: /${version}/reference/method/Mongo.setSecondaryOk -> ${base}/${version}/reference/method/Mongo.setReadPref/ +[v5.0-*]: /${version}/reference/method/rs.secondaryOk.txt -> ${base}/${version}/reference/replica-configuration/ [v5.0-*]: /${version}/mongo -> ${base}/${version}/reference/mongo/ # diff --git a/source/core/retryable-writes.txt b/source/core/retryable-writes.txt index 9b6d181a9bd..f4705a4e849 100644 --- a/source/core/retryable-writes.txt +++ b/source/core/retryable-writes.txt @@ -93,7 +93,7 @@ cannot be :writeconcern:`{w: 0} <\>`. .. note:: The write operations inside the :doc:`transactions - ` are not individually retryable. + ` are not individually retryable. .. list-table:: :header-rows: 1 @@ -109,7 +109,6 @@ cannot be :writeconcern:`{w: 0} <\>`. * - | :method:`db.collection.updateOne()` | :method:`db.collection.replaceOne()` - | :method:`db.collection.save()` | :method:`db.collection.update()` where ``multi`` is ``false`` - Single-document update operations. [#duplicate-key-update]_ @@ -165,10 +164,10 @@ cannot be :writeconcern:`{w: 0} <\>`. details, see :ref:`update-shard-key`. .. [#duplicate-key-update] - + MongoDB 4.2 will retry certain single-document upserts - (update with ``upsert: true`` and ``multi: false``) that encounter a - duplicate key exception. See :ref:`retryable-update-upsert` for + (update with ``upsert: true`` and ``multi: false``) that encounter a + duplicate key exception. See :ref:`retryable-update-upsert` for conditions. Prior to MongoDB 4.2, MongoDB would not retry upsert operations @@ -207,7 +206,7 @@ the failover period exceeds :urioption:`serverSelectionTimeoutMS`. Duplicate Key Errors on Upsert ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -MongoDB 4.2 will retry single-document upsert operations +MongoDB 4.2 will retry single-document upsert operations (i.e ``upsert : true`` and ``multi : false``) that fail due to a duplicate key error *only if* the operation meets *all* of the following conditions: diff --git a/source/core/transactions-operations.txt b/source/core/transactions-operations.txt index 525bfd6d41c..8f104dc193e 100644 --- a/source/core/transactions-operations.txt +++ b/source/core/transactions-operations.txt @@ -134,9 +134,6 @@ operations against a :red:`non-existing` collection: - :dbcommand:`insert` - * - :method:`db.collection.save()` results in an insert - - - * - | :method:`db.collection.updateOne()` with ``upsert: true`` | :method:`db.collection.updateMany()` with ``upsert: true`` | :method:`db.collection.replaceOne()` with ``upsert: true`` diff --git a/source/includes/extracts-4.2-changes.yaml b/source/includes/extracts-4.2-changes.yaml index 7c294d1b28b..83b3af613f3 100644 --- a/source/includes/extracts-4.2-changes.yaml +++ b/source/includes/extracts-4.2-changes.yaml @@ -814,10 +814,10 @@ content: | document. In earlier versions, these operations only attempt to target using the replacement document. - - The :method:`~db.collection.save()` method is deprecated: use the + - The ``save()`` method is deprecated: use the :method:`~db.collection.insertOne()` or :method:`~db.collection.replaceOne()` method instead. The - :method:`~db.collection.save()` method cannot be used with + ``save()`` method cannot be used with sharded collections that are *not* sharded by ``_id``, and attempting to do so will result in an error. diff --git a/source/includes/fact-getSecondaryOk.rst b/source/includes/fact-getSecondaryOk.rst deleted file mode 100644 index 7cefac5d15c..00000000000 --- a/source/includes/fact-getSecondaryOk.rst +++ /dev/null @@ -1,2 +0,0 @@ -Indicates whether the MongoDB connection allows read operations on -:term:`secondary` members. \ No newline at end of file diff --git a/source/includes/fact-mongosh-callout.rst b/source/includes/fact-mongosh-callout.rst index 5c21dbfee81..69caf005a14 100644 --- a/source/includes/fact-mongosh-callout.rst +++ b/source/includes/fact-mongosh-callout.rst @@ -4,8 +4,8 @@ included in the `MongoDB Server Download `__. - For information on the new MongoDB Shell, ``mongosh``, refer to the - :mongosh:`mongosh Documentation `. + For information on the new MongoDB Shell (``mongosh``) refer to the + :mongosh:`mongosh documentation `. To understand the differences between the two shells, see :ref:`compare-mongosh-mongo`. diff --git a/source/includes/fact-secondaryOk.rst b/source/includes/fact-secondaryOk.rst deleted file mode 100644 index 3a86e1cdea9..00000000000 --- a/source/includes/fact-secondaryOk.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. include:: /includes/fact-setSecondaryOk.rst - -Also means that :term:`eventually consistent ` -read operations are acceptable for the current application. See -:method:`readPref() ` for additional -fine-grained settings for the :doc:`read preference -`. \ No newline at end of file diff --git a/source/includes/fact-setSecondaryOk.rst b/source/includes/fact-setSecondaryOk.rst deleted file mode 100644 index 5e3cebb8f40..00000000000 --- a/source/includes/fact-setSecondaryOk.rst +++ /dev/null @@ -1,2 +0,0 @@ -Allows read operations on :term:`secondary` members for the MongoDB -connection. \ No newline at end of file diff --git a/source/includes/table-transactions-operations.rst b/source/includes/table-transactions-operations.rst index 24ccb65f3ce..15a7a5fbf3f 100644 --- a/source/includes/table-transactions-operations.rst +++ b/source/includes/table-transactions-operations.rst @@ -84,18 +84,6 @@ :ref:`transactions-operations-ddl` - * - :method:`db.collection.save()` - - - - Starting in MongoDB 4.4, if run on a non-existing - collection, the collection is implicitly created. - - In MongoDB 4.2 and earlier, the operation must be run on an - existing collection. - - .. seealso:: - - :ref:`transactions-operations-ddl` - * - | :method:`db.collection.updateOne()` | :method:`db.collection.updateMany()` | :method:`db.collection.replaceOne()` diff --git a/source/reference/command/convertToCapped.txt b/source/reference/command/convertToCapped.txt index de13e3e370e..0ccbd43e3ad 100644 --- a/source/reference/command/convertToCapped.txt +++ b/source/reference/command/convertToCapped.txt @@ -99,13 +99,13 @@ Example Convert a Collection ~~~~~~~~~~~~~~~~~~~~ -The following example uses a :method:`db.collection.save()` operation to create +The following example uses :method:`db.collection.insertOne()` to create an ``events`` collection, and :method:`db.collection.stats()` to obtain information about the collection: .. code-block:: javascript - db.events.save( { click: 'button-1', time: new Date() } ) + db.events.insertOne( { click: 'button-1', time: new Date() } ) db.events.stats() MongoDB will return the following: diff --git a/source/reference/insert-methods.txt b/source/reference/insert-methods.txt index efa8f72a7ab..fb491ac56c3 100644 --- a/source/reference/insert-methods.txt +++ b/source/reference/insert-methods.txt @@ -49,8 +49,6 @@ The following methods can also add new documents to a collection: - :method:`db.collection.findOneAndReplace()` when used with the ``upsert: true`` option. -- :method:`db.collection.save()`. - - :method:`db.collection.bulkWrite()`. See the individual reference pages for the methods for more information diff --git a/source/reference/method.txt b/source/reference/method.txt index 4adfb811052..1aac8f1ee2d 100644 --- a/source/reference/method.txt +++ b/source/reference/method.txt @@ -35,10 +35,6 @@ Collection - Provides bulk write operation functionality. - * - :method:`db.collection.copyTo()` - - - Deprecated. Copies data between collections when run against MongoDB 4.0 or earlier. Unsupported when run against MongoDB 4.2 or later. - * - :method:`db.collection.count()` - Wraps :dbcommand:`count` to return a count of the number of documents in a collection or a view. @@ -177,10 +173,6 @@ Collection - Replaces a single document in a collection. - * - :method:`db.collection.save()` - - - Provides a wrapper around an :method:`~db.collection.insert()` and :method:`~db.collection.update()` to insert new documents. - * - :method:`db.collection.stats()` - Reports on the state of a collection. Provides a wrapper around the :dbcommand:`collStats`. @@ -570,9 +562,7 @@ Database - Opens a :ref:`change stream cursor ` for a database to report on all its non-``system`` collections. Cannot be opened on - the ``admin``, ``local`` or ``config`` databases. - - + the ``admin``, ``local`` or ``config`` databases. .. toctree:: :titlesonly: @@ -596,28 +586,24 @@ Query Plan Cache - Returns an interface to access the query plan cache object and associated PlanCache methods for a collection. - * - :method:`PlanCache.clear()` - Clears all the cached query plans for a collection. Accessible through the plan cache object of a specific collection, i.e. ``db.collection.getPlanCache().clear()``. - * - :method:`PlanCache.clearPlansByQuery()` - Clears the cached query plans for the specified query shape. Accessible through the plan cache object of a specific collection, i.e. ``db.collection.getPlanCache().clearPlansByQuery()`` - * - :method:`PlanCache.help()` - Displays the methods available for a collection's query plan cache. Accessible through the plan cache object of a specific collection, i.e. ``db.collection.getPlanCache().help()``. - * - :method:`PlanCache.list()` - Returns the plan cache information for a collection. Accessible @@ -749,32 +735,26 @@ User Management - Creates a new user. - * - :method:`db.dropUser()` - Removes a single user. - * - :method:`db.dropAllUsers()` - Deletes all users associated with a database. - * - :method:`db.getUser()` - Returns information about the specified user. - * - :method:`db.getUsers()` - Returns information about all users associated with a database. - * - :method:`db.grantRolesToUser()` - Grants a role and its privileges to a user. - * - :method:`db.removeUser()` - Deprecated. Removes a user from a database. @@ -783,12 +763,10 @@ User Management - Removes a role from a user. - * - :method:`db.updateUser()` - Updates user data. - * - :method:`passwordPrompt()` - Prompts for the password as an alternative to specifying passwords @@ -820,47 +798,38 @@ Role Management - Creates a role and specifies its privileges. - * - :method:`db.dropRole()` - Deletes a user-defined role. - * - :method:`db.dropAllRoles()` - Deletes all user-defined roles associated with a database. - * - :method:`db.getRole()` - Returns information for the specified role. - * - :method:`db.getRoles()` - Returns information for all the user-defined roles in a database. - * - :method:`db.grantPrivilegesToRole()` - Assigns privileges to a user-defined role. - * - :method:`db.revokePrivilegesFromRole()` - Removes the specified privileges from a user-defined role. - * - :method:`db.grantRolesToRole()` - Specifies roles from which a user-defined role inherits privileges. - * - :method:`db.revokeRolesFromRole()` - Removes inherited roles from a role. - * - :method:`db.updateRole()` - Updates a user-defined role. @@ -932,10 +901,6 @@ Replication - Remove a member from a replica set. - * - :method:`rs.secondaryOk()` - - - Allows read operations on a secondary member. - * - :method:`rs.status()` - Returns a document with information about the state of the replica set. @@ -1217,14 +1182,6 @@ Connection - Returns the read preference tag set for the MongoDB connection. - * - :method:`Mongo.getSecondaryOk()` - - - .. include:: /includes/fact-getSecondaryOk.rst - - * - :method:`Mongo.isCausalConsistency()` - - - Indicates whether causal consistency is enabled on the connection object. - * - :method:`Mongo.setCausalConsistency()` - Enables or disables causal consistency on the connection object. @@ -1233,10 +1190,6 @@ Connection - Sets the :term:`read preference` for the MongoDB connection. - * - :method:`Mongo.setSecondaryOk()` - - - .. include:: /includes/fact-setSecondaryOk.rst - * - :method:`Mongo.startSession()` - Starts a session on the connection object. diff --git a/source/reference/method/Mongo.getSecondaryOk.txt b/source/reference/method/Mongo.getSecondaryOk.txt deleted file mode 100644 index fe27a7c478a..00000000000 --- a/source/reference/method/Mongo.getSecondaryOk.txt +++ /dev/null @@ -1,36 +0,0 @@ -====================== -Mongo.getSecondaryOk() -====================== - -.. default-domain:: mongodb - -.. contents:: On this page - :local: - :backlinks: none - :depth: 1 - :class: singlecol - -Definition ----------- - -.. method:: Mongo.getSecondaryOk() - - .. include:: /includes/fact-getSecondaryOk.rst - - :returns: ``True`` if the MongoDB connection allows read - operations on :term:`secondary` members. Otherwise, returns - ``false``. - -Example -------- - -This example calls :method:`~Mongo.getSecondaryOk()`: - -.. code-block:: javascript - - db.getMongo().getSecondaryOk() - -.. seealso:: - - - :method:`Mongo.setSecondaryOk()` - - :method:`rs.secondaryOk()` \ No newline at end of file diff --git a/source/reference/method/Mongo.isCausalConsistency.txt b/source/reference/method/Mongo.isCausalConsistency.txt deleted file mode 100644 index 06336f16cda..00000000000 --- a/source/reference/method/Mongo.isCausalConsistency.txt +++ /dev/null @@ -1,42 +0,0 @@ -============================ -Mongo.isCausalConsistency() -============================ - -.. default-domain:: mongodb - -.. contents:: On this page - :local: - :backlinks: none - :depth: 1 - :class: singlecol - -Definition ----------- - -.. method:: Mongo.isCausalConsistency() - - .. versionadded:: 3.6 - - Returns a boolean that indicates whether :ref:`causal consistency - ` is enabled on the connection object. - - .. code-block:: javascript - - var conn = Mongo("localhost:27017"); - conn.isCausalConsistency() - -Example -------- - -The following :binary:`~bin.mongo` shell operation determines if causal -consistency is enabled on the :method:`Mongo` connection object -associated with the :binary:`~bin.mongo` shell's global ``db`` variable: - -.. code-block:: javascript - - db.getMongo().isCausalConsistency(); - -.. seealso:: - - - :method:`db.getMongo()` - - :method:`Mongo.setCausalConsistency()` diff --git a/source/reference/method/Mongo.setCausalConsistency.txt b/source/reference/method/Mongo.setCausalConsistency.txt index 270dd83d22c..4207db65937 100644 --- a/source/reference/method/Mongo.setCausalConsistency.txt +++ b/source/reference/method/Mongo.setCausalConsistency.txt @@ -15,8 +15,6 @@ Definition .. method:: Mongo.setCausalConsistency() - .. versionadded:: 3.6 - Enables or disables :ref:`causal consistency ` on the connection object. Causal consistency is disabled on the connection object by default. @@ -60,15 +58,7 @@ the :binary:`~bin.mongo` shell's global ``db`` variable: db.getMongo().setCausalConsistency(); -To check if causal consistency is enabled for a connection, use the -:method:`Mongo.isCausalConsistency()` method. For example: - -.. code-block:: javascript - - db.getMongo().isCausalConsistency(); - .. seealso:: - :method:`db.getMongo()` - - :method:`Mongo.isCausalConsistency()` diff --git a/source/reference/method/Mongo.setSecondaryOk.txt b/source/reference/method/Mongo.setSecondaryOk.txt deleted file mode 100644 index 699812b5999..00000000000 --- a/source/reference/method/Mongo.setSecondaryOk.txt +++ /dev/null @@ -1,32 +0,0 @@ -====================== -Mongo.setSecondaryOk() -====================== - -.. default-domain:: mongodb - -.. contents:: On this page - :local: - :backlinks: none - :depth: 1 - :class: singlecol - -Definition ----------- - -.. method:: Mongo.setSecondaryOk() - - .. include:: /includes/fact-secondaryOk.rst - -Example -------- - -This example calls :method:`~Mongo.setSecondaryOk()`: - -.. code-block:: javascript - - db.getMongo().setSecondaryOk() - -.. seealso:: - - - :method:`Mongo.getSecondaryOk()` - - :method:`rs.secondaryOk()` \ No newline at end of file diff --git a/source/reference/method/SessionOptions.txt b/source/reference/method/SessionOptions.txt index be37709e204..4dcf6aedd63 100644 --- a/source/reference/method/SessionOptions.txt +++ b/source/reference/method/SessionOptions.txt @@ -35,16 +35,10 @@ Definition - Boolean. Enables or disables :ref:`causal consistency ` for the session. - In the :binary:`~bin.mongo` shell, :method:`Mongo.startSession()` - enables ``causalConsistency`` by default. You can also - explicitly set the option when you run - :method:`Mongo.startSession()`. - - You can view whether ``causalConsistency`` is enabled for the - session via the following method: - - - ``Session.getOptions().isCausalConsistency()`` - + You can explicitly set the option when you start a session + manually: + + - ``Session = db.getMongo().startSession( { causalConsistency: true } )`` * - ``readConcern`` @@ -58,7 +52,6 @@ Definition - ``Session.getOptions().setReadConcern()`` - * - ``readPreference`` - Document. Specifies the :ref:`read preference `. @@ -97,3 +90,7 @@ Definition - ``Session.getOptions().getWriteConcern()`` - ``Session.getOptions().setWriteConcern()`` + +Verify which options are enabled for the session by running +``Session.getOptions()``. + diff --git a/source/reference/method/WriteResult.txt b/source/reference/method/WriteResult.txt index f344373ad47..b6ab609378c 100644 --- a/source/reference/method/WriteResult.txt +++ b/source/reference/method/WriteResult.txt @@ -23,7 +23,6 @@ Definition - :method:`db.collection.insert()` - :method:`db.collection.update()` - :method:`db.collection.remove()` - - :method:`db.collection.save()` Properties ---------- diff --git a/source/reference/method/db.collection.copyTo.txt b/source/reference/method/db.collection.copyTo.txt deleted file mode 100644 index 04c14b23713..00000000000 --- a/source/reference/method/db.collection.copyTo.txt +++ /dev/null @@ -1,60 +0,0 @@ -====================== -db.collection.copyTo() -====================== - -.. default-domain:: mongodb - -.. contents:: On this page - :local: - :backlinks: none - :depth: 1 - :class: singlecol - -Definition ----------- - -.. method:: db.collection.copyTo(newCollection) - - - .. include:: /includes/fact-mongosh-shell-method.rst - - - .. deprecated:: 3.0 - - .. important:: - - Starting in version 4.2, MongoDB removes the ``eval`` command. - The deprecated :method:`db.collection.copyTo()`, which wraps the - ``eval`` command, can only be run against MongoDB 4.0 or earlier - versions. For behavior and example, refer to the 4.0 or earlier - version of the manual. - - Copies all documents from ``collection`` into ``newCollection`` using - server-side JavaScript. If ``newCollection`` does not exist, MongoDB - creates it. - - - .. list-table:: - :header-rows: 1 - :widths: 20 20 80 - - * - Parameter - - - Type - - - Description - - * - ``newCollection`` - - - string - - - The name of the collection to write data to. - - - - - - :method:`db.collection.copyTo()` returns the number of documents - copied. If the copy fails, it throws an exception. - - diff --git a/source/reference/method/db.collection.save.txt b/source/reference/method/db.collection.save.txt deleted file mode 100644 index f67e8128775..00000000000 --- a/source/reference/method/db.collection.save.txt +++ /dev/null @@ -1,233 +0,0 @@ -==================== -db.collection.save() -==================== - -.. default-domain:: mongodb - -.. contents:: On this page - :local: - :backlinks: none - :depth: 1 - :class: singlecol - -Definition ----------- - -.. method:: db.collection.save() - - - .. include:: /includes/fact-mongosh-shell-method.rst - - - Updates an existing :doc:`document ` or inserts a - new document, depending on its ``document`` parameter. - - .. note:: - - Starting in MongoDB 4.2, the :method:`db.collection.save()` method - is deprecated. Use :method:`db.collection.insertOne()` or - :method:`db.collection.replaceOne()` instead. - - The :method:`~db.collection.save()` method has the following form: - - .. code-block:: none - - db.collection.save( - , - { - writeConcern: - } - ) - - - .. list-table:: - :header-rows: 1 - :widths: 20 20 80 - - * - Parameter - - - Type - - - Description - - * - ``document`` - - - document - - - A document to save to the collection. - - - - * - ``writeConcern`` - - - document - - - Optional. A document expressing the :doc:`write concern - `. Omit to use the default write concern. - See :ref:`save-wc`. - - .. include:: /includes/extracts/transactions-operations-write-concern.rst - - The :method:`~db.collection.save()` returns an object that - contains the status of the operation. - - :returns: A :ref:`writeresults-save` object that contains the - status of the operation. - -Behavior --------- - -.. _save-wc: - -Write Concern -~~~~~~~~~~~~~ - -The :method:`~db.collection.save()` method uses either the -:dbcommand:`insert` or the :dbcommand:`update` command, which use the -default :doc:`write concern `. To specify a -different write concern, include the write concern in the options -parameter. - -Insert -~~~~~~ - -If the document does **not** contain an :term:`_id` field, then the -:method:`~db.collection.save()` method calls the -:method:`~db.collection.insert()` method. During the operation, the -:binary:`~bin.mongo` shell will create an :method:`ObjectId` and -assign it to the ``_id`` field. - -.. include:: /includes/note-insert-id-field.rst - -Update -~~~~~~ - -If the document contains an :term:`_id` field, then the -:method:`~db.collection.save()` method is equivalent to an update with -the :ref:`upsert option ` set to ``true`` and the -query predicate on the ``_id`` field. - -Transactions -~~~~~~~~~~~~ - -.. include:: /includes/extracts/transactions-supported-operation.rst - -.. include:: /includes/extracts/4.4-changes-transactions-save.rst - -.. include:: /includes/extracts/transactions-operations-write-concern.rst - -.. include:: /includes/extracts/transactions-usage.rst - -.. |operation| replace:: :method:`db.collection.save()` - -Sharded Clusters -~~~~~~~~~~~~~~~~ - -Starting in MongoDB 4.2, the :method:`~db.collection.save()` method -cannot be used with sharded collections that are *not* sharded by -``_id``, and attempting to do so will result in an error. Use the -:method:`~db.collection.insertOne()` or -:method:`~db.collection.replaceOne()` method instead. - -.. _save-method-examples: - -Examples --------- - -.. _crud-create-insert-save: - -Save a New Document without Specifying an ``_id`` Field -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In the following example, :method:`~db.collection.save()` method -performs an insert since the document passed to the method does not -contain the ``_id`` field: - -.. code-block:: javascript - - db.products.save( { item: "book", qty: 40 } ) - -During the insert, the shell will create the ``_id`` field with -a unique :method:`ObjectId` value, as verified by the inserted -document: - -.. code-block:: javascript - - { "_id" : ObjectId("50691737d386d8fadbd6b01d"), "item" : "book", "qty" : 40 } - -.. include:: /includes/fact-object-id-may-differ.rst - -.. _crud-create-save: - -Save a New Document Specifying an ``_id`` Field -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In the following example, :method:`~db.collection.save()` performs an -update with ``upsert:true`` since the document contains an ``_id`` field: - -.. code-block:: javascript - - db.products.save( { _id: 100, item: "water", qty: 30 } ) - -Because the ``_id`` field holds a value that *does not* exist in the -collection, the update operation results in an insertion of the -document. The results of these operations are identical to an -:ref:`update() method with the upsert option ` set to -``true``. - -The operation results in the following new document in the ``products`` -collection: - -.. code-block:: javascript - - { "_id" : 100, "item" : "water", "qty" : 30 } - -Replace an Existing Document -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The ``products`` collection contains the following document: - -.. code-block:: javascript - - { "_id" : 100, "item" : "water", "qty" : 30 } - -The :method:`~db.collection.save()` method performs an update with -``upsert:true`` since the document contains an ``_id`` field: - -.. code-block:: javascript - - db.products.save( { _id : 100, item : "juice" } ) - -Because the ``_id`` field holds a value that exists in the collection, -the operation performs an update to replace the document and results in -the following document: - -.. code-block:: javascript - - { "_id" : 100, "item" : "juice" } - -Override Default Write Concern -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The following operation to a replica set specifies a :doc:`write -concern ` of ``"w: majority"`` with a -``wtimeout`` of 5000 milliseconds such that the method returns after -the write propagates to a majority of the voting replica set members or -the method times out after 5 seconds. - -.. code-block:: javascript - - db.products.save( - { item: "envelopes", qty : 100, type: "Clasp" }, - { writeConcern: { w: "majority", wtimeout: 5000 } } - ) - -.. _writeresults-save: - -WriteResult ------------ - -The :method:`~db.collection.save()` returns a :method:`WriteResult` -object that contains the status of the insert or update operation. See -:ref:`WriteResult for insert ` and -:ref:`WriteResult for update ` for details. diff --git a/source/reference/method/js-collection.txt b/source/reference/method/js-collection.txt index 76bd79a4f1a..4e8b7ba8a48 100644 --- a/source/reference/method/js-collection.txt +++ b/source/reference/method/js-collection.txt @@ -32,10 +32,6 @@ Collection Methods - Provides bulk write operation functionality. - * - :method:`db.collection.copyTo()` - - - Deprecated. Copies data between collections when run against MongoDB 4.0 or earlier. Unsupported when run against MongoDB 4.2 or later. - * - :method:`db.collection.count()` - Wraps :dbcommand:`count` to return a count of the number of documents in a collection or a view. @@ -174,10 +170,6 @@ Collection Methods - Replaces a single document in a collection. - * - :method:`db.collection.save()` - - - Provides a wrapper around an :method:`~db.collection.insert()` and :method:`~db.collection.update()` to insert new documents. - * - :method:`db.collection.stats()` - Reports on the state of a collection. Provides a wrapper around the :dbcommand:`collStats`. @@ -225,7 +217,6 @@ Collection Methods /reference/method/db.collection.aggregate /reference/method/db.collection.bulkWrite - /reference/method/db.collection.copyTo /reference/method/db.collection.count /reference/method/db.collection.countDocuments /reference/method/db.collection.createIndex @@ -260,7 +251,6 @@ Collection Methods /reference/method/db.collection.remove /reference/method/db.collection.renameCollection /reference/method/db.collection.replaceOne - /reference/method/db.collection.save /reference/method/db.collection.stats /reference/method/db.collection.storageSize /reference/method/db.collection.totalIndexSize diff --git a/source/reference/method/js-connection.txt b/source/reference/method/js-connection.txt index c0be32fd91c..3427fe48864 100644 --- a/source/reference/method/js-connection.txt +++ b/source/reference/method/js-connection.txt @@ -40,14 +40,6 @@ Connection Methods - Returns the read preference tag set for the MongoDB connection. - * - :method:`Mongo.getSecondaryOk()` - - - .. include:: /includes/fact-getSecondaryOk.rst - - * - :method:`Mongo.isCausalConsistency()` - - - Indicates whether causal consistency is enabled on the connection object. - * - :method:`Mongo.setCausalConsistency()` - Enables or disables causal consistency on the connection object. @@ -56,10 +48,6 @@ Connection Methods - Sets the :term:`read preference` for the MongoDB connection. - * - :method:`Mongo.setSecondaryOk()` - - - .. include:: /includes/fact-setSecondaryOk.rst - * - :method:`Mongo.startSession()` - Starts a session on the connection object. @@ -90,11 +78,8 @@ Connection Methods /reference/method/Mongo.getDB /reference/method/Mongo.getReadPrefMode /reference/method/Mongo.getReadPrefTagSet - /reference/method/Mongo.getSecondaryOk - /reference/method/Mongo.isCausalConsistency /reference/method/Mongo.setCausalConsistency /reference/method/Mongo.setReadPref - /reference/method/Mongo.setSecondaryOk /reference/method/Mongo.startSession /reference/method/Mongo.watch /reference/method/Session diff --git a/source/reference/method/js-replication.txt b/source/reference/method/js-replication.txt index d5770372b1e..6e82f9063df 100644 --- a/source/reference/method/js-replication.txt +++ b/source/reference/method/js-replication.txt @@ -66,10 +66,6 @@ Replication Methods - Remove a member from a replica set. - * - :method:`rs.secondaryOk()` - - - .. include:: /includes/fact-setSecondaryOk.rst - * - :method:`rs.status()` - Returns a document with information about the state of the replica set. @@ -98,7 +94,6 @@ Replication Methods /reference/method/rs.printSlaveReplicationInfo /reference/method/rs.reconfig /reference/method/rs.remove - /reference/method/rs.secondaryOk /reference/method/rs.status /reference/method/rs.stepDown /reference/method/rs.syncFrom diff --git a/source/reference/method/rs.secondaryOk.txt b/source/reference/method/rs.secondaryOk.txt deleted file mode 100644 index bdf9dc19bd1..00000000000 --- a/source/reference/method/rs.secondaryOk.txt +++ /dev/null @@ -1,34 +0,0 @@ -================ -rs.secondaryOk() -================ - -.. default-domain:: mongodb - -.. contents:: On this page - :local: - :backlinks: none - :depth: 1 - :class: singlecol - -Definition ----------- - -.. method:: rs.secondaryOk() - - .. include:: /includes/fact-secondaryOk.rst - - :method:`rs.secondaryOk()` calls :method:`Mongo.setSecondaryOk()`. - -Example -------- - -This example calls :method:`rs.secondaryOk()`: - -.. code-block:: javascript - - rs.secondaryOk() - -.. seealso:: - - - :method:`Mongo.setSecondaryOk()` - - :method:`Mongo.getSecondaryOk()` \ No newline at end of file diff --git a/source/reference/mongo-shell.txt b/source/reference/mongo-shell.txt index e38723a821a..6ee1a11d2d1 100644 --- a/source/reference/mongo-shell.txt +++ b/source/reference/mongo-shell.txt @@ -201,11 +201,6 @@ The following table displays some common JavaScript operations: - Update multiple existing documents in the collection. - * - :method:`db.collection.save()` - - - Insert either a new document or update an existing document in - the collection. - * - :method:`db.collection.deleteOne()` - Delete a single document from the collection. diff --git a/source/reference/mongo.txt b/source/reference/mongo.txt index 5135044e149..89f0d1434a9 100644 --- a/source/reference/mongo.txt +++ b/source/reference/mongo.txt @@ -30,7 +30,7 @@ Legacy ``mongo`` Shell Comparison of the ``mongo`` Shell and ``mongosh`` ------------------------------------------------- -The new MongoDB Shell, :mongosh:`mongosh `, offers numerous +The new MongoDB Shell (:mongosh:`mongosh `) offers numerous advantages over the :binary:`~bin.mongo` shell, such as: - Improved syntax highlighting. diff --git a/source/reference/replication.txt b/source/reference/replication.txt index be2cb765e60..09a21a9a45f 100644 --- a/source/reference/replication.txt +++ b/source/reference/replication.txt @@ -67,10 +67,6 @@ Replication Methods in the ``mongo`` Shell - Remove a member from a replica set. - * - :method:`rs.secondaryOk()` - - - .. include:: /includes/fact-setSecondaryOk.rst - * - :method:`rs.status()` - Returns a document with information about the state of the replica set. diff --git a/source/reference/update-methods.txt b/source/reference/update-methods.txt index 0584b7d5ad1..faddc8699b1 100644 --- a/source/reference/update-methods.txt +++ b/source/reference/update-methods.txt @@ -53,8 +53,6 @@ The following methods can also update documents from a collection: - :method:`db.collection.findAndModify()`. -- :method:`db.collection.save()`. - - :method:`db.collection.bulkWrite()`. See the individual reference pages for the methods for more information diff --git a/source/release-notes/2.6-compatibility.txt b/source/release-notes/2.6-compatibility.txt index 8e3992d2dac..58c8335c842 100644 --- a/source/release-notes/2.6-compatibility.txt +++ b/source/release-notes/2.6-compatibility.txt @@ -46,23 +46,22 @@ Description Inserts will error: - :method:`db.collection.insert()` and other operations that perform - inserts (e.g. :method:`db.collection.save()` and + inserts (e.g. ``db.collection.save()`` and :method:`db.collection.update()` with ``upsert`` that result in inserts) will fail to insert if the new document has an indexed field whose corresponding index entry exceeds the limit. Previous versions of MongoDB would insert but not index such documents. - - :binary:`~bin.mongorestore` and :binary:`~bin.mongoimport` will fail to - insert if the new document has an indexed field whose + - :binary:`~bin.mongorestore` and :binary:`~bin.mongoimport` will + fail to insert if the new document has an indexed field whose corresponding index entry exceeds the limit. Updates will error: - :method:`db.collection.update()` and - :method:`db.collection.save()` operations on an indexed field will - error if the updated value causes the index entry to exceed the - limit. + ``db.collection.save()`` operations on an indexed field will error + if the updated value causes the index entry to exceed the limit. - If an existing document contains an indexed field whose index entry exceeds the limit, updates on other fields that result in @@ -167,7 +166,7 @@ Write Method Acknowledgements Description The :binary:`~bin.mongo` shell write methods :method:`db.collection.insert()`, :method:`db.collection.update()`, - :method:`db.collection.save()` and :method:`db.collection.remove()` + ``db.collection.save()`` and :method:`db.collection.remove()` now integrate the :doc:`write concern ` directly into the method rather than with a separate :dbcommand:`getLastError` command to provide :ref:`acknowledgement of writes @@ -185,7 +184,7 @@ Description and write concern errors, and obviates the need to call :dbcommand:`getLastError` command to get the status of the results. See :method:`db.collection.insert()`, - :method:`db.collection.update()`, :method:`db.collection.save()` + :method:`db.collection.update()`, ``db.collection.save()`` and :method:`db.collection.remove()` for details. - In sharded environments, :binary:`~bin.mongos` no longer supports @@ -536,8 +535,8 @@ Description Solution - For existing documents that have fields with empty names ``""``, replace the whole document. See :method:`db.collection.update()` - and :method:`db.collection.save()` for details on replacing an - existing document. + and ``db.collection.save()`` for details on replacing an existing + document. - For existing documents that have fields with names that contain a dot (``.``), either replace the whole document or :update:`unset diff --git a/source/release-notes/3.0-compatibility.txt b/source/release-notes/3.0-compatibility.txt index 3727521737b..01c9d46f356 100644 --- a/source/release-notes/3.0-compatibility.txt +++ b/source/release-notes/3.0-compatibility.txt @@ -545,7 +545,7 @@ The following commands and methods are deprecated in MongoDB 3.0: - ``eval``, ``db.eval()`` -- :method:`db.collection.copyTo()` +- ``db.collection.copyTo()`` In addition, you cannot use the now deprecated ``eval`` command or the ``db.eval()`` method to invoke :dbcommand:`mapReduce` or diff --git a/source/release-notes/3.6.txt b/source/release-notes/3.6.txt index 42f6643b475..82be59f7c89 100644 --- a/source/release-notes/3.6.txt +++ b/source/release-notes/3.6.txt @@ -832,7 +832,7 @@ the :binary:`~bin.mongo` shell. The option enables The following new methods have been added to the ``Mongo()`` connection object in the :binary:`~bin.mongo` shell: -- :method:`Mongo.isCausalConsistency()` +- ``Mongo.isCausalConsistency()`` - :method:`Mongo.startSession()` diff --git a/source/release-notes/4.2-compatibility.txt b/source/release-notes/4.2-compatibility.txt index 4c0684f4aa7..da7791ce75a 100644 --- a/source/release-notes/4.2-compatibility.txt +++ b/source/release-notes/4.2-compatibility.txt @@ -93,7 +93,7 @@ Starting in version 4.2, MongoDB removes the ``eval`` command. The ``eval`` command has been deprecated since version 3.0. The associated MongoDB 4.2 :binary:`~bin.mongo` shell methods -``db.eval()`` and :method:`db.collection.copyTo()` can only be run when +``db.eval()`` and ``db.collection.copyTo()`` can only be run when connected to MongoDB 4.0 or earlier. .. _4.2-compat-remove-copydb-clone: diff --git a/source/release-notes/4.2.txt b/source/release-notes/4.2.txt index 9eccecbbe60..cc2d8d7c8eb 100644 --- a/source/release-notes/4.2.txt +++ b/source/release-notes/4.2.txt @@ -484,7 +484,7 @@ Removed Commands and Methods - - The MongoDB 4.2 :binary:`~bin.mongo` shell methods ``db.eval()`` - and :method:`db.collection.copyTo()` can only be run when + and ``db.collection.copyTo()`` can only be run when connected to MongoDB 4.0 or earlier. diff --git a/source/release-notes/5.0-compatibility.txt b/source/release-notes/5.0-compatibility.txt index 2baf5e2ca90..6c74d8e49a7 100644 --- a/source/release-notes/5.0-compatibility.txt +++ b/source/release-notes/5.0-compatibility.txt @@ -59,12 +59,34 @@ Starting in MongoDB 5.0, these database commands and * - Removed Command - Alternative + * - ``db.collection.copyTo()`` + - :pipeline:`$out` + * - :method:`db.collection.ensureIndex()` - :method:`db.collection.createIndex()` + * - ``db.collection.save()`` + - | :method:`db.collection.insertOne()` + | :method:`db.collection.insertMany()` + * - :method:`db.resetError()` - Not available + * - :dbcommand:`geoSearch` + - One of the :ref:`Geospatial Query Operators ` + + * - ``Mongo.getSecondaryOk()`` + - :doc:`/reference/method/Mongo.getReadPrefMode` + + * - ``Mongo.isCausalConsistency`` + - Not available + + * - ``Mongo.setSecondaryOk()`` + - :doc:`/reference/method/Mongo.setReadPref` + + * - ``rs.secondaryOk()`` + - :doc:`/reference/method/Mongo.setReadPref` + * - :dbcommand:`resetError` - Not available @@ -74,10 +96,6 @@ Starting in MongoDB 5.0, these database commands and * - :dbcommand:`unsetSharding` - Not available - * - :dbcommand:`geoSearch` - - :pipeline:`$geoNear` or one of the supported - :ref:`geospatial query operators ` - Removed Parameters ------------------ diff --git a/source/tutorial/access-mongo-shell-help.txt b/source/tutorial/access-mongo-shell-help.txt index 1486ac76d91..8d603ff53e8 100644 --- a/source/tutorial/access-mongo-shell-help.txt +++ b/source/tutorial/access-mongo-shell-help.txt @@ -111,11 +111,11 @@ In the :binary:`~bin.mongo` shell: - To see the collection method implementation, type the ``db..`` name without the parenthesis (``()``), as in the following example which will return the implementation of - the :method:`~db.collection.save()` method: + the :method:`~db.collection.insertOne()` method: .. code-block:: javascript - db.collection.save + db.collection.insertOne .. _mongo-shell-help-cursor: diff --git a/source/tutorial/configure-audit-filters.txt b/source/tutorial/configure-audit-filters.txt index 8b02711c5fa..5f8fd3f884e 100644 --- a/source/tutorial/configure-audit-filters.txt +++ b/source/tutorial/configure-audit-filters.txt @@ -223,7 +223,7 @@ successes using the :parameter:`auditAuthorizationSuccess` parameter. The following example audits the :method:`~db.collection.find()`, :method:`~db.collection.insert()`, :method:`~db.collection.remove()`, -:method:`~db.collection.update()`, :method:`~db.collection.save()`, and +:method:`~db.collection.update()`, and :method:`~db.collection.findAndModify()` operations by using the filter: .. code-block:: bash @@ -268,7 +268,7 @@ successes using the :parameter:`auditAuthorizationSuccess` parameter. The following example audits the :method:`~db.collection.find()`, :method:`~db.collection.insert()`, :method:`~db.collection.remove()`, -:method:`~db.collection.update()`, :method:`~db.collection.save()`, and +:method:`~db.collection.update()`, and :method:`~db.collection.findAndModify()` operations for the collection ``orders`` in the database ``test`` by using the filter: diff --git a/source/tutorial/modify-chunk-size-in-sharded-cluster.txt b/source/tutorial/modify-chunk-size-in-sharded-cluster.txt index 86703f18f26..7559d2212d7 100644 --- a/source/tutorial/modify-chunk-size-in-sharded-cluster.txt +++ b/source/tutorial/modify-chunk-size-in-sharded-cluster.txt @@ -29,12 +29,12 @@ To modify the chunk size, use the following procedure: use config -#. Issue the following :method:`~db.collection.save()` operation to - store the global chunk size configuration value: +#. Issue the following command to store the global chunk size + configuration value: .. code-block:: javascript - db.settings.save( { _id:"chunksize", value: } ) + db.settings.insertOne( { _id:"chunksize", value: } ) Modifying the chunk size has several limitations: