diff --git a/source/includes/5.0-changes/fact-getLastError-alternatives.rst b/source/includes/5.0-changes/fact-getLastError-alternatives.rst new file mode 100644 index 00000000000..e434f3eada1 --- /dev/null +++ b/source/includes/5.0-changes/fact-getLastError-alternatives.rst @@ -0,0 +1,6 @@ +Any code explicitly using ``getLastError``, ``db.getLastError()``, or +``db.getLastErrorObj()`` should instead use the CRUD API to issue the +write with the desired :ref:`write concern `. +Information about the success or failure of the write operation will be +provided directly by the driver as a return value. + diff --git a/source/includes/5.1/fact-wont-connect-past-3.6.rst b/source/includes/5.1/fact-wont-connect-past-3.6.rst new file mode 100644 index 00000000000..82a14ce42b7 --- /dev/null +++ b/source/includes/5.1/fact-wont-connect-past-3.6.rst @@ -0,0 +1,5 @@ +Starting in MongoDB 5.1, certain wire protocol opcodes are removed from +the :binary:`~bin.mongo` shell. The shell will not connect to any +version of :binary:`~bin.mongod` or :binary:`~bin.mongos` less than +3.6 since these versions do not support the OP_MSG RPC protocol. + diff --git a/source/includes/5.1/removed-shell-parameters.rst b/source/includes/5.1/removed-shell-parameters.rst new file mode 100644 index 00000000000..72b5a9efb71 --- /dev/null +++ b/source/includes/5.1/removed-shell-parameters.rst @@ -0,0 +1,22 @@ +MongoDB 5.1 removes the following parameters from the +:binary:`~bin.mongo` shell: + +.. list-table:: + :header-rows: 1 + :widths: 25 75 + + * - Removed Parameters + - Description + * - ``--useLegacyWriteOps`` + - The ability to use OP_INSERT, OP_UPDATE, and OP_DELETE is + removed. The shell will only use OP_MSG write commands. + * - ``--writeMode`` + - The ability to use OP_INSERT, OP_UPDATE, and OP_DELETE is + removed. The shell will only use OP_MSG write commands. + * - ``--readMode`` + - The ability to use OP_QUERY legacy find is removed. The shell + will only use OP_MSG find commands. + * - ``--rpcProtocols`` + - Support for the OP_QUERY RPC protocol is removed. The shell + will always use the OP_MSG RPC protocol. + diff --git a/source/includes/fact-write-concern-spec-link.rst b/source/includes/fact-write-concern-spec-link.rst new file mode 100644 index 00000000000..83f57e73e8d --- /dev/null +++ b/source/includes/fact-write-concern-spec-link.rst @@ -0,0 +1,3 @@ +Optional. The level of :ref:`write concern ` for the +operation. See :ref:`wc-specs`. + diff --git a/source/includes/note-bulk-inserts-on-sharded-clusters.rst b/source/includes/note-bulk-inserts-on-sharded-clusters.rst index 6d6d17cf6bc..5dae6bf0e6b 100644 --- a/source/includes/note-bulk-inserts-on-sharded-clusters.rst +++ b/source/includes/note-bulk-inserts-on-sharded-clusters.rst @@ -1,6 +1,6 @@ .. note:: - For bulk inserts on sharded clusters, the :dbcommand:`getLastError` + For bulk inserts on sharded clusters, the ``getLastError`` command alone is insufficient to verify success. Applications should must verify the success of bulk inserts in application logic. diff --git a/source/reference/command.txt b/source/reference/command.txt index 856adba74a4..37b977f687f 100644 --- a/source/reference/command.txt +++ b/source/reference/command.txt @@ -131,10 +131,6 @@ Query and Write Operation Commands - Returns and modifies a single document. - * - :dbcommand:`getLastError` - - - Returns the success status of the last operation. - * - :dbcommand:`getMore` - Returns batches of documents currently pointed to by the cursor. diff --git a/source/reference/command/createRole.txt b/source/reference/command/createRole.txt index 212f5415bb1..0d668e298ed 100644 --- a/source/reference/command/createRole.txt +++ b/source/reference/command/createRole.txt @@ -53,69 +53,35 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``createRole`` - - string - - The name of the new role. - - - * - ``privileges`` - - array - - The privileges to grant the role. A privilege consists of a resource and permitted actions. For the syntax of a privilege, see the :data:`~admin.system.roles.privileges` array. You must include the ``privileges`` field. Use an empty array to specify *no* privileges. - - - * - ``roles`` - - array - - An array of roles from which this role inherits privileges. You must include the ``roles`` field. Use an empty array to specify *no* roles to inherit from. - - - * - ``authenticationRestrictions`` - - array - - Optional. - .. include:: /includes/fact-auth-restrictions-role-desc.rst - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` to apply - to this operation. The ``writeConcern`` document uses the same fields - as the :dbcommand:`getLastError` command. - - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - .. versionadded:: 4.4 .. |local-cmd-name| replace:: :dbcommand:`createRole` diff --git a/source/reference/command/createUser.txt b/source/reference/command/createUser.txt index 3db870a6d38..1e5c8d9ae25 100644 --- a/source/reference/command/createUser.txt +++ b/source/reference/command/createUser.txt @@ -54,23 +54,13 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``createUser`` - - string - - The name of the new user. - - - * - ``pwd`` - - string - - The user's password. The ``pwd`` field is not required if you run |local-cmd-name| on the ``$external`` database to create users who have credentials stored externally to @@ -79,81 +69,52 @@ Definition The value can be either: - the user's password in cleartext string, or - - :method:`passwordPrompt()` to prompt for the user's password. - + .. tip:: .. include:: /includes/extracts/4.2-changes-passwordPrompt.rst - - - + * - ``customData`` - - document - - Optional. Any arbitrary information. This field can be used to store any data an admin wishes to associate with this particular user. For example, this could be the user's full name or employee id. - - - + * - ``roles`` - - array - - The roles granted to the user. Can specify an empty array ``[]`` to create users without roles. - - - + * - ``digestPassword`` - - boolean - - Optional. Indicates whether the server or the client digests the password. - + If true, the server receives undigested password from the client and digests the password. - + If false, the client digests the password and passes the digested password to the server. Not compatible with ``SCRAM-SHA-256`` - + .. versionchanged:: 4.0 The default value is ``true``. In earlier versions, the default value is ``false``. - - - + * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - creation operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``authenticationRestrictions`` - - array - - Optional. The authentication restrictions the server enforces on the created user. Specifies a list of IP addresses and :abbr:`CIDR (Classless Inter-Domain Routing)` ranges from which the user is allowed to connect to the server or from which the server can accept users. - + .. versionadded:: 3.6 - - - * - ``mechanisms`` - - array - - Optional. Specify the specific SCRAM mechanism or mechanisms for creating SCRAM user credentials. If :parameter:`authenticationMechanisms` is specified, you can only specify a subset of the @@ -162,16 +123,11 @@ Definition Valid values are: - ``"SCRAM-SHA-1"`` - - - Uses the ``SHA-1`` hashing function. - + - Uses the ``SHA-1`` hashing function. - ``"SCRAM-SHA-256"`` - - - Uses the ``SHA-256`` hashing function. - - - Requires featureCompatibilityVersion set to ``4.0``. - - - Requires digestPassword to be ``true``. + - Uses the ``SHA-256`` hashing function. + - Requires featureCompatibilityVersion set to ``4.0``. + - Requires digestPassword to be ``true``. The default for featureCompatibilityVersion is ``4.0`` is both ``SCRAM-SHA-1`` and ``SCRAM-SHA-256``. @@ -180,13 +136,9 @@ Definition ``SCRAM-SHA-1``. .. versionadded:: 4.0 - - - + * - ``digestPassword`` - - boolean - - Optional. Indicates whether the server or the client digests the password. If true, the server receives undigested password from the client and @@ -199,14 +151,11 @@ Definition The default value is ``true``. In earlier versions, the default value is ``false``. - - - * - ``comment`` + * - ``comment`` - any - - .. include:: /includes/extracts/comment-content.rst - + .. versionadded:: 4.4 diff --git a/source/reference/command/dropAllRolesFromDatabase.txt b/source/reference/command/dropAllRolesFromDatabase.txt index 5e5008f7ebf..3c24b4a88f7 100644 --- a/source/reference/command/dropAllRolesFromDatabase.txt +++ b/source/reference/command/dropAllRolesFromDatabase.txt @@ -42,37 +42,20 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``dropAllRolesFromDatabase`` - - integer - - Specify ``1`` to drop all :ref:`user-defined ` roles from the database where the command is run. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - removal operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - /includes/source/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - - .. versionadded:: 4.4 + .. versionadded:: 4.4 Required Access --------------- diff --git a/source/reference/command/dropAllUsersFromDatabase.txt b/source/reference/command/dropAllUsersFromDatabase.txt index 8e0a0a838f7..10fea512e8e 100644 --- a/source/reference/command/dropAllUsersFromDatabase.txt +++ b/source/reference/command/dropAllUsersFromDatabase.txt @@ -41,34 +41,18 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``dropAllUsersFromDatabase`` - - integer - - Specify ``1`` to drop all the users from the current database. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - removal operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - + .. versionadded:: 4.4 diff --git a/source/reference/command/dropRole.txt b/source/reference/command/dropRole.txt index 2ed51cbefd7..195be10be44 100644 --- a/source/reference/command/dropRole.txt +++ b/source/reference/command/dropRole.txt @@ -30,41 +30,24 @@ Definition The :dbcommand:`dropRole` command has the following fields: - .. list-table:: :header-rows: 1 :widths: 20 20 80 * - Field - - Type - - Description - * - ``dropRole`` - - string - - The name of the :ref:`user-defined role ` to remove from the database. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - removal operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - + .. versionadded:: 4.4 diff --git a/source/reference/command/dropUser.txt b/source/reference/command/dropUser.txt index 82ad3b488c1..4bcc2a93afb 100644 --- a/source/reference/command/dropUser.txt +++ b/source/reference/command/dropUser.txt @@ -35,34 +35,18 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``dropUser`` - - string - - The name of the user to delete. You must issue the :dbcommand:`dropUser` command while using the database where the user exists. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - removal operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst .. versionadded:: 4.4 diff --git a/source/reference/command/getLastError.txt b/source/reference/command/getLastError.txt index 928cb68fdfd..327d12748ef 100644 --- a/source/reference/command/getLastError.txt +++ b/source/reference/command/getLastError.txt @@ -10,268 +10,9 @@ getLastError :depth: 1 :class: singlecol -Definition ----------- - .. dbcommand:: getLastError - Starting in MongoDB 5.0, :dbcommand:`getLastError` is deprecated. For - more information and alternatives, see :ref:`Deprecated Wire Protocol - Opcodes `. - - .. include:: /includes/extracts/fact-2.6-wc-gle-change-cmd-getLastError.rst - - Returns the error status of the preceding write operation on the - *current connection*. - - :dbcommand:`getLastError` uses the following prototype form: - - .. code-block:: javascript - - { getLastError: 1 } - - :dbcommand:`getLastError` uses the following fields: - - - .. list-table:: - :header-rows: 1 - :widths: 20 20 80 - - * - Field - - - Type - - - Description - - * - ``j`` - - - boolean - - - If ``true``, wait for the next journal commit before returning, rather - than waiting for a full disk flush. If :binary:`~bin.mongod` does not have - journaling enabled, this option has no effect. If this option is - enabled for a write operation, :binary:`~bin.mongod` will wait *no more* - than 1/3 of the current :setting:`~storage.journal.commitIntervalMs` before - writing data to the journal. - - - - * - ``w`` - - - integer or string - - - When running with replication, this is the number of servers to - replicate to before returning. A ``w`` value of 1 indicates the - primary only. A ``w`` value of 2 includes the primary and at least - one secondary, etc. In place of a number, you may also set ``w`` to - ``majority`` to indicate that the command should wait until the - latest write propagates to a majority of the voting replica set - members. - - If using ``w``, you should also use ``wtimeout``. Specifying - a value for ``w`` without also providing a ``wtimeout`` may cause - :dbcommand:`getLastError` to block indefinitely. - - - - * - ``wtimeout`` - - - integer - - - Optional. Milliseconds. Specify a value in milliseconds to control how - long to wait for write propagation to complete. If replication does - not complete in the given timeframe, the :dbcommand:`getLastError` - command will return with an error status. - - - * - ``comment`` - - - any - - - .. include:: /includes/extracts/comment-content.rst - - .. versionadded:: 4.4 - - - .. seealso:: - - :doc:`/reference/write-concern` - -.. _getLastError-output: - -Output ------- - -Each :dbcommand:`getLastError` command returns a document containing a -subset of the fields listed below. - -.. data:: getLastError.ok - - :data:`~getLastError.ok` is ``true`` when the - :dbcommand:`getLastError` command completes successfully. - - .. note:: A value of ``true`` does *not* indicate that the preceding - operation did not produce an error. - -.. data:: getLastError.err - - :data:`~getLastError.err` is ``null`` unless an error occurs. When - there was an error with the preceding operation, ``err`` contains - a string identifying the error. - -.. data:: getLastError.ns - - If the error is a duplicate key error, returns the namespace of the - collection. - - .. versionadded:: 4.4 - -.. data:: getLastError.index - - If the error is a duplicate key error, returns the index whose - unique key constraint is violated. - - .. versionadded:: 4.4 - -.. data:: getLastError.errmsg - - :data:`~getLastError.errmsg` contains the description of the error. - :data:`~getLastError.errmsg` only appears if there was an error with - the preceding operation. - -.. data:: getLastError.code - - :data:`~getLastError.code` reports the preceding operation's error - code. For description of the error, see :data:`~getLastError.err` - and :data:`~getLastError.errmsg`. - -.. data:: getLastError.connectionId - - The identifier of the connection. - -.. data:: getLastError.lastOp - - When issued against a replica set member and the preceding - operation was a write or update, :data:`~getLastError.lastOp` is the - *optime* timestamp in the :term:`oplog` of the change. - -.. data:: getLastError.n - - If the preceding operation was an update or a remove operation, but - *not* a :dbcommand:`findAndModify` operation, - :data:`~getLastError.n` reports the number of documents matched by - the update or remove operation. - - For a remove operation, the number of matched documents will equal - the number removed. - - For an update operation, if the operation results in no - change to the document, such as setting the value of the field to - its current value, the number of matched documents may be smaller - than the number of documents actually modified. If the update - includes the ``upsert:true`` option and results in the creation of a - new document, :data:`~getLastError.n` returns the number of - documents inserted. - - :data:`~getLastError.n` is ``0`` if reporting on an update or remove - that occurs through a :dbcommand:`findAndModify` operation. - -.. data:: getLastError.syncMillis - - :data:`~getLastError.syncMillis` is the number of milliseconds spent - waiting for the write to disk operation (e.g. write to journal - files). - -.. data:: getLastError.shards - - When issued against a sharded cluster after a write operation, - :data:`~getLastError.shards` identifies the shards targeted in the - write operation. :data:`~getLastError.shards` is present in the - output only if the write operation targets multiple shards. - -.. data:: getLastError.singleShard - - When issued against a sharded cluster after a write operation, - identifies the shard targeted in the write operation. - :data:`~getLastError.singleShard` is only present if the write - operation targets exactly one shard. - -.. data:: getLastError.updatedExisting - - :data:`~getLastError.updatedExisting` is ``true`` when an update - affects at least one document and does not result in an - :term:`upsert`. - -.. data:: getLastError.upserted - - If the update results in an insert, :data:`~getLastError.upserted` - is the value of ``_id`` field of the document. - -.. data:: getLastError.wnote - - If set, ``wnote`` indicates that the preceding operation's error - relates to using the ``w`` parameter to :dbcommand:`getLastError`. - - .. see:: - - :doc:`/reference/write-concern` for more information about - ``w`` values. - -.. data:: getLastError.wtimeout - - :data:`~getLastError.wtimeout` is ``true`` if the - :dbcommand:`getLastError` timed out because of the ``wtimeout`` - setting to :dbcommand:`getLastError`. - -.. data:: getLastError.waited - - If the preceding operation specified a timeout using the - ``wtimeout`` setting to :dbcommand:`getLastError`, then - :data:`~getLastError.waited` reports the number of milliseconds - :dbcommand:`getLastError` waited before timing out. - -.. data:: getLastError.wtime - - :data:`getLastError.wtime` is the number of milliseconds spent - waiting for the preceding operation to complete. If - :dbcommand:`getLastError` timed out, :data:`~getLastError.wtime` and - :data:`~getLastError.waited` are equal. - -.. data:: getLastError.writtenTo - - If writing to a replica set, :data:`~getLastError.writtenTo` is an - array that contains the hostname and port number of the members that - confirmed the previous write operation, based on the value of the - ``w`` field in the command. - -.. _gle-examples: - -Examples --------- - -Confirm Replication to Two Replica Set Members -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The following example ensures the preceding operation has replicated to -two members (the primary and one other member). The command also -specifies a timeout of ``5000`` milliseconds to ensure that -the :dbcommand:`getLastError` command does not block forever if MongoDB -cannot satisfy the requested write concern: - -.. code-block:: javascript - - db.runCommand( { getLastError: 1, w: 2, wtimeout:5000 } ) - -Confirm Replication to a Majority of a Replica Set -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The following example ensures the write operation has replicated to a -majority of the voting members of the replica set. The command also -specifies a timeout of ``5000`` milliseconds to ensure that -the :dbcommand:`getLastError` command does not block forever if MongoDB -cannot satisfy the requested write concern: - -.. code-block:: javascript +Removed in MongoDB 5.1. - db.runCommand( { getLastError: 1, w: "majority", wtimeout:5000 } ) +.. include:: /includes/5.0-changes/fact-getLastError-alternatives.rst diff --git a/source/reference/command/grantPrivilegesToRole.txt b/source/reference/command/grantPrivilegesToRole.txt index 85f9a4dd56d..1107d83b05b 100644 --- a/source/reference/command/grantPrivilegesToRole.txt +++ b/source/reference/command/grantPrivilegesToRole.txt @@ -43,43 +43,21 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``grantPrivilegesToRole`` - - string - - The name of the user-defined role to grant privileges to. - - - * - ``privileges`` - - array - - The privileges to add to the role. For the format of a privilege, see :data:`~admin.system.roles.privileges`. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - .. versionadded:: 4.4 diff --git a/source/reference/command/grantRolesToRole.txt b/source/reference/command/grantRolesToRole.txt index 606e408c759..060d6cf1e5e 100644 --- a/source/reference/command/grantRolesToRole.txt +++ b/source/reference/command/grantRolesToRole.txt @@ -40,42 +40,20 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``grantRolesToRole`` - - string - - The name of a role to add subsidiary roles. - - - * - ``roles`` - - array - - An array of roles from which to inherit. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - .. versionadded:: 4.4 diff --git a/source/reference/command/grantRolesToUser.txt b/source/reference/command/grantRolesToUser.txt index 5ce1ff8581f..904dcf3b3f6 100644 --- a/source/reference/command/grantRolesToUser.txt +++ b/source/reference/command/grantRolesToUser.txt @@ -35,45 +35,22 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``grantRolesToUser`` - - string - - The name of the user to give additional roles. - - - * - ``roles`` - - array - - An array of additional roles to grant to the user. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - .. versionadded:: 4.4 - .. |local-cmd-name| replace:: :dbcommand:`grantRolesToUser` .. include:: /includes/fact-roles-array-contents.rst diff --git a/source/reference/command/nav-crud.txt b/source/reference/command/nav-crud.txt index 856aeea4bbf..b42ce3e26a6 100644 --- a/source/reference/command/nav-crud.txt +++ b/source/reference/command/nav-crud.txt @@ -34,7 +34,7 @@ Query and Write Operation Commands * - :dbcommand:`getLastError` - - Returns the success status of the last operation. + - Removed in MongoDB 5.1. * - :dbcommand:`getMore` diff --git a/source/reference/command/revokePrivilegesFromRole.txt b/source/reference/command/revokePrivilegesFromRole.txt index b836ef90d37..e5f42646b06 100644 --- a/source/reference/command/revokePrivilegesFromRole.txt +++ b/source/reference/command/revokePrivilegesFromRole.txt @@ -41,45 +41,23 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``revokePrivilegesFromRole`` - - string - - The :ref:`user-defined ` role to revoke privileges from. - - - * - ``privileges`` - - array - - An array of privileges to remove from the role. See :data:`~admin.system.roles.privileges` for more information on the format of the privileges. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - .. versionadded:: 4.4 diff --git a/source/reference/command/revokeRolesFromRole.txt b/source/reference/command/revokeRolesFromRole.txt index 6b4e62e457e..f93ac151c4c 100644 --- a/source/reference/command/revokeRolesFromRole.txt +++ b/source/reference/command/revokeRolesFromRole.txt @@ -37,42 +37,20 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``revokeRolesFromRole`` - - string - - The role from which to remove inherited roles. - - - * - ``roles`` - - array - - The inherited roles to remove. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` to apply - to this operation. The ``writeConcern`` document uses the same fields - as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - .. versionadded:: 4.4 diff --git a/source/reference/command/revokeRolesFromUser.txt b/source/reference/command/revokeRolesFromUser.txt index d8666fcc14a..5e293756c28 100644 --- a/source/reference/command/revokeRolesFromUser.txt +++ b/source/reference/command/revokeRolesFromUser.txt @@ -36,47 +36,24 @@ Definition .. list-table:: :header-rows: 1 :widths: 20 20 80 - + * - Field - - Type - - Description - * - ``revokeRolesFromUser`` - - string - - The user to remove roles from. - - - * - ``roles`` - - array - - The roles to remove from the user. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - .. versionadded:: 4.4 - .. |local-cmd-name| replace:: :dbcommand:`revokeRolesFromUser` .. include:: /includes/fact-roles-array-contents.rst diff --git a/source/reference/command/serverStatus.txt b/source/reference/command/serverStatus.txt index 561c33697b2..e4f26646150 100644 --- a/source/reference/command/serverStatus.txt +++ b/source/reference/command/serverStatus.txt @@ -5200,41 +5200,40 @@ metrics .. serverstatus:: metrics.getLastError - A document that reports on :dbcommand:`getLastError` use. + A document that reports on :ref:`write concern ` use. .. serverstatus:: metrics.getLastError.wtime - A document that reports :dbcommand:`getLastError` operation counts - with a ``w`` argument greater than ``1``. + A document that reports :ref:`write concern ` + operation counts with a ``w`` argument greater than ``1``. .. serverstatus:: metrics.getLastError.wtime.num - The total number of :dbcommand:`getLastError` operations with a - specified write concern (i.e. ``w``) that wait for one or more - members of a replica set to acknowledge the write operation (i.e. a - ``w`` value greater than ``1``.) + The total number of operations with a specified write concern + (i.e. ``w``) that wait for one or more members of a replica set to + acknowledge the write operation (i.e. a ``w`` value greater than + ``1``.) .. serverstatus:: metrics.getLastError.wtime.totalMillis - The total amount of time in milliseconds that the :binary:`~bin.mongod` - has spent performing :dbcommand:`getLastError` operations with write - concern (i.e. ``w``) that wait for one or more members of a replica - set to acknowledge the write operation (i.e. a ``w`` value greater - than ``1``.) + The total amount of time in milliseconds that the + :binary:`~bin.mongod` has spent performing :ref:`write concern + ` operations with a write concern (i.e. ``w``) that + waits for one or more members of a replica set to acknowledge the + write operation (i.e. a ``w`` value greater than ``1``.) .. serverstatus:: metrics.getLastError.wtimeouts The number of times that :term:`write concern` operations have timed - out as a result of the ``wtimeout`` threshold to - :dbcommand:`getLastError`. This number increments for both default - and non-default write concern specifications. + out as a result of the ``wtimeout`` threshold. This number + increments for both default and non-default write concern + specifications. .. serverstatus:: metrics.getLastError.default - A document that reports on the use of :dbcommand:`getLastError` - specific to operations where a default write concern was used - (meaning, a non-``clientSupplied`` write concern). The possible - origins of a default write concern are: + A document that reports on when a default :ref:`write concern + ` was used (meaning, a non-``clientSupplied`` write + concern). The possible origins of a default write concern are: - ``implicitDefault`` - ``customDefault`` diff --git a/source/reference/command/updateRole.txt b/source/reference/command/updateRole.txt index 165dfc21dcc..bea58075958 100644 --- a/source/reference/command/updateRole.txt +++ b/source/reference/command/updateRole.txt @@ -72,64 +72,32 @@ Definition * - Field - Type - - Description - * - ``updateRole`` - - string - - The name of the :ref:`user-defined role ` role to update. - - - * - ``privileges`` - - array - - Optional. Required if you do not specify :data:`~admin.system.roles.roles` array. The privileges to grant the role. An update to the ``privileges`` array overrides the previous array's values. For the syntax for specifying a privilege, see the :data:`~admin.system.roles.privileges` array. - - - * - ``roles`` - - array - - Optional. Required if you do not specify :data:`~admin.system.roles.privileges` array. The roles from which this role inherits privileges. An update to the ``roles`` array overrides the previous array's values. - - - * - ``authenticationRestrictions`` - - array - - Optional. - .. include:: /includes/fact-auth-restrictions-role-desc.rst - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - update operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``comment`` - - any - - .. include:: /includes/extracts/comment-content.rst - .. versionadded:: 4.4 diff --git a/source/reference/command/updateUser.txt b/source/reference/command/updateUser.txt index 36b8ffc84ac..b4fcb2bc832 100644 --- a/source/reference/command/updateUser.txt +++ b/source/reference/command/updateUser.txt @@ -69,66 +69,34 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``updateUser`` - - string - - The name of the user to update. - - - * - ``pwd`` - - string - - Optional. The user's password. The value can be either: - + - the user's password in cleartext string, or - - :method:`passwordPrompt()` to prompt for the user's password. - + .. tip:: - + .. include:: /includes/extracts/4.2-changes-passwordPrompt.rst - - - + * - ``customData`` - - document - - Optional. Any arbitrary information. - - - * - ``roles`` - - array - - Optional. The roles granted to the user. An update to the ``roles`` array overrides the previous array's values. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - update operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - + - .. include:: /includes/fact-write-concern-spec-link.rst * - ``authenticationRestrictions`` - - array - - Optional. The authentication restrictions the server enforces upon the user. Specifies a list of IP addresses and :abbr:`CIDR (Classless Inter-Domain Routing)` ranges from which the @@ -136,13 +104,8 @@ Definition accept users. .. versionadded:: 3.6 - - - * - ``mechanisms`` - - array - - Optional. The specific SCRAM mechanism or mechanisms for the user credentials. If :parameter:`authenticationMechanisms` is specified, you can only specify a subset of the :parameter:`authenticationMechanisms`. diff --git a/source/reference/method.txt b/source/reference/method.txt index acee8d0e393..7e6bfe08443 100644 --- a/source/reference/method.txt +++ b/source/reference/method.txt @@ -441,14 +441,6 @@ Database - Lists all collections and views in the current database. - * - :method:`db.getLastError()` - - - Checks and returns the status of the last operation. Wraps :dbcommand:`getLastError`. - - * - :method:`db.getLastErrorObj()` - - - Returns the status document for the last operation. Wraps :dbcommand:`getLastError`. - * - :method:`db.getLogComponents()` - Returns the log message verbosity levels. diff --git a/source/reference/method/db.changeUserPassword.txt b/source/reference/method/db.changeUserPassword.txt index 66bd41b4cfd..44171cea80c 100644 --- a/source/reference/method/db.changeUserPassword.txt +++ b/source/reference/method/db.changeUserPassword.txt @@ -25,46 +25,25 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``username`` - - string - - The name of the user whose password you wish to change. - - - * - ``password`` - - string - - The user's password. The value can be either: - + - the user's password in cleartext string, or - - :method:`passwordPrompt()` to prompt for the user's password. - + .. tip:: - + .. include:: /includes/extracts/4.2-changes-passwordPrompt.rst - - - + * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - creation operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst Required Access --------------- diff --git a/source/reference/method/db.createRole.txt b/source/reference/method/db.createRole.txt index cb8343140b3..196916aede1 100644 --- a/source/reference/method/db.createRole.txt +++ b/source/reference/method/db.createRole.txt @@ -28,30 +28,14 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``role`` - - document - - A document containing the name of the role and the role definition. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` to apply - to this operation. The ``writeConcern`` document uses the same fields - as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The ``role`` document has the following form: diff --git a/source/reference/method/db.createUser.txt b/source/reference/method/db.createUser.txt index 1a7a94b1d34..b6742f0966a 100644 --- a/source/reference/method/db.createUser.txt +++ b/source/reference/method/db.createUser.txt @@ -27,31 +27,15 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``user`` - - document - - The document with authentication and access information about the user to create. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - creation operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The ``user`` document defines the user and has the following form: diff --git a/source/reference/method/db.dropAllRoles.txt b/source/reference/method/db.dropAllRoles.txt index 034327f8c7e..6c3a56095f5 100644 --- a/source/reference/method/db.dropAllRoles.txt +++ b/source/reference/method/db.dropAllRoles.txt @@ -31,22 +31,11 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - removal operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst .. COMMENT I added the returns here because in the example for this method, you have what the method returns. But we don't specify diff --git a/source/reference/method/db.dropAllUsers.txt b/source/reference/method/db.dropAllUsers.txt index a58ffe8f3b2..21222de7f9f 100644 --- a/source/reference/method/db.dropAllUsers.txt +++ b/source/reference/method/db.dropAllUsers.txt @@ -31,22 +31,11 @@ Definition :widths: 20 20 80 * - Field - - Type - - Description - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - removal operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The :method:`db.dropAllUsers()` method wraps the :dbcommand:`dropAllUsersFromDatabase` command. diff --git a/source/reference/method/db.dropRole.txt b/source/reference/method/db.dropRole.txt index fdcf1def005..b839f68e768 100644 --- a/source/reference/method/db.dropRole.txt +++ b/source/reference/method/db.dropRole.txt @@ -26,31 +26,15 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``rolename`` - - string - - The name of the :ref:`user-defined role ` to remove from the database. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - removal operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The :method:`db.dropRole()` method wraps the :dbcommand:`dropRole` command. diff --git a/source/reference/method/db.dropUser.txt b/source/reference/method/db.dropUser.txt index 59d64530748..2d5f31bdd36 100644 --- a/source/reference/method/db.dropUser.txt +++ b/source/reference/method/db.dropUser.txt @@ -25,30 +25,14 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``username`` - - string - - The name of the user to remove from the database. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - removal operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The :method:`db.dropUser()` method wraps the :dbcommand:`dropUser` command. diff --git a/source/reference/method/db.getLastError.txt b/source/reference/method/db.getLastError.txt index 636df2b23ea..e152f6ff11d 100644 --- a/source/reference/method/db.getLastError.txt +++ b/source/reference/method/db.getLastError.txt @@ -10,69 +10,9 @@ db.getLastError() :depth: 1 :class: singlecol -Definition ----------- -.. method:: db.getLastError(, ) - Starting in MongoDB 5.0, :method:`db.getLastError()` is deprecated. - For more information and alternatives, see :ref:`Deprecated Wire - Protocol Opcodes `. +Removed in MongoDB 5.1. - .. include:: /includes/extracts/db.getLastError-definition.rst +.. include:: /includes/5.0-changes/fact-getLastError-alternatives.rst - .. include:: /includes/extracts/fact-2.6-wc-gle-change-method-db.getLastError.rst - - The :method:`db.getLastError()` can accept the following parameters: - - - .. list-table:: - :header-rows: 1 - :widths: 20 20 80 - - * - Parameter - - - Type - - - Description - - * - ``w`` - - - int or string - - - Optional. The write concern's ``w`` value. - - - - * - ``wtimeout`` - - - int - - - Optional. The time limit in milliseconds. - - - - - -Behavior --------- - -.. include:: /includes/extracts/db.getLastError-behavior.rst - -Example -------- - -The following example issues a :method:`db.getLastError()` operation -that verifies that the preceding write operation, issued over the same -connection, has propagated to at least two members of the replica set. - -.. code-block:: javascript - - db.getLastError(2) - -.. seealso:: - - :dbcommand:`getLastError` and :doc:`/reference/write-concern` for - all options, :ref:`Write Concern ` for a conceptual - overview, :doc:`/crud` for information about all - write operations in MongoDB. diff --git a/source/reference/method/db.getLastErrorObj.txt b/source/reference/method/db.getLastErrorObj.txt index ac7921ad459..704a898e399 100644 --- a/source/reference/method/db.getLastErrorObj.txt +++ b/source/reference/method/db.getLastErrorObj.txt @@ -10,102 +10,8 @@ db.getLastErrorObj() :depth: 1 :class: singlecol -Definition ----------- -.. method:: db.getLastErrorObj(w, wtimeout, j) +Removed in MongoDB 5.1. - Starting in MongoDB 5.0, :method:`db.getLastErrorObj()` is - deprecated. For more information and alternatives, see - :ref:`Deprecated Wire Protocol Opcodes - `. +.. include:: /includes/5.0-changes/fact-getLastError-alternatives.rst - .. include:: /includes/extracts/db.getLastErrorObj-definition.rst - - .. include:: /includes/extracts/fact-2.6-wc-gle-change-method-db.getLastErrorObj.rst - - The :method:`db.getLastErrorObj()` can accept the following - parameters: - - - .. list-table:: - :header-rows: 1 - :widths: 20 20 80 - - * - Parameter - - - Type - - - Description - - * - ``w`` - - - int or string - - - Optional. The write concern's ``w`` value. - - - - * - ``wtimeout`` - - - int - - - Optional. The time limit in milliseconds. - - - * - ``j`` - - - boolean - - - If ``true``, wait for the next journal commit before returning, rather - than waiting for a full disk flush. If :binary:`~bin.mongod` does not have - journaling enabled, this option has no effect. If this option is - enabled for a write operation, :binary:`~bin.mongod` will wait *no more* - than 1/3 of the current :setting:`~storage.journal.commitIntervalMs` before - writing data to the journal. - - - -Behavior --------- - -.. include:: /includes/extracts/db.getLastErrorObj-behavior.rst - -Example -------- - -The following example issues a :method:`db.getLastErrorObj()` operation -that verifies that the preceding write operation, issued over the same -connection, has propagated to at least two members of the replica set. - -.. code-block:: javascript - - db.getLastErrorObj(2) - -If the last error object is a duplicate key error, the method returns -a document similar to the following: - -.. code-block:: javascript - - { - "err" : "E11000 duplicate key error collection: test.foobar index: x_1 dup key: { x: 1.0 }", - "ns" : "test.foobar", // New in 4.4 - "index" : "x_1", // New in 4.4 - "code" : 11000, - "codeName" : "DuplicateKey", - "n" : 0, - "singleShard" : "m1.example.net:27017", - "ok" : 1, - "operationTime" : Timestamp(1584654273, 1), - "$clusterTime" : { - "clusterTime" : Timestamp(1584654274, 1), - "signature" : { - "hash" : BinData(0,"Z3L9FdEIYQ2MwLg6X/4sDWacqzM="), - "keyId" : NumberLong("6806025526243754005") - } - } - } - -.. seealso:: - - :doc:`/reference/write-concern`. diff --git a/source/reference/method/db.grantPrivilegesToRole.txt b/source/reference/method/db.grantPrivilegesToRole.txt index 53794ccd3fc..18f2ff4ef15 100644 --- a/source/reference/method/db.grantPrivilegesToRole.txt +++ b/source/reference/method/db.grantPrivilegesToRole.txt @@ -39,39 +39,18 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``rolename`` - - string - - The name of the role to grant privileges to. - - - * - ``privileges`` - - array - - The privileges to add to the role. For the format of a privilege, see :data:`~admin.system.roles.privileges`. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The :method:`db.grantPrivilegesToRole()` method can grant one or more privileges. Each ```` has the following syntax: diff --git a/source/reference/method/db.grantRolesToRole.txt b/source/reference/method/db.grantRolesToRole.txt index 1b3382319ef..d4271702a3a 100644 --- a/source/reference/method/db.grantRolesToRole.txt +++ b/source/reference/method/db.grantRolesToRole.txt @@ -32,38 +32,17 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``rolename`` - - string - - The name of the role to which to grant sub roles. - - - * - ``roles`` - - array - - An array of roles from which to inherit. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst .. |local-cmd-name| replace:: :method:`db.grantRolesToRole()` .. include:: /includes/fact-roles-array-contents.rst diff --git a/source/reference/method/db.grantRolesToUser.txt b/source/reference/method/db.grantRolesToUser.txt index 666ffc88c7d..c7a74cce7bc 100644 --- a/source/reference/method/db.grantRolesToUser.txt +++ b/source/reference/method/db.grantRolesToUser.txt @@ -31,38 +31,17 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``user`` - - string - - The name of the user to whom to grant roles. - - - * - ``roles`` - - array - - An array of additional roles to grant to the user. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst .. |local-cmd-name| replace:: :method:`db.grantRolesToUser()` .. include:: /includes/fact-roles-array-contents.rst diff --git a/source/reference/method/db.revokePrivilegesFromRole.txt b/source/reference/method/db.revokePrivilegesFromRole.txt index a3fb6f017e0..f2f0da1cad4 100644 --- a/source/reference/method/db.revokePrivilegesFromRole.txt +++ b/source/reference/method/db.revokePrivilegesFromRole.txt @@ -38,41 +38,20 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``rolename`` - - string - - The name of the :ref:`user-defined ` role from which to revoke privileges. - - - * - ``privileges`` - - array - - An array of privileges to remove from the role. See :data:`~admin.system.roles.privileges` for more information on the format of the privileges. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The :method:`db.revokePrivilegesFromRole()` method wraps the :dbcommand:`revokePrivilegesFromRole` command. diff --git a/source/reference/method/db.revokeRolesFromRole.txt b/source/reference/method/db.revokeRolesFromRole.txt index 7d5aad0feeb..f9050d8cfaf 100644 --- a/source/reference/method/db.revokeRolesFromRole.txt +++ b/source/reference/method/db.revokeRolesFromRole.txt @@ -31,38 +31,17 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``rolename`` - - string - - The name of the role from which to revoke roles. - - - * - ``roles`` - - array - - The inherited roles to remove. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` to apply - to this operation. The ``writeConcern`` document uses the same fields - as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst .. |local-cmd-name| replace:: :method:`db.revokeRolesFromRole()` .. include:: /includes/fact-roles-array-contents.rst diff --git a/source/reference/method/db.revokeRolesFromUser.txt b/source/reference/method/db.revokeRolesFromUser.txt index b87f4af3bfe..f9063189527 100644 --- a/source/reference/method/db.revokeRolesFromUser.txt +++ b/source/reference/method/db.revokeRolesFromUser.txt @@ -31,38 +31,17 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``user`` - - string - - The name of the user from whom to revoke roles. - - - * - ``roles`` - - array - - The roles to remove from the user. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - modification. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst .. |local-cmd-name| replace:: :method:`db.revokeRolesFromUser()` .. include:: /includes/fact-roles-array-contents.rst diff --git a/source/reference/method/db.updateRole.txt b/source/reference/method/db.updateRole.txt index 01f959c7313..700a755062a 100644 --- a/source/reference/method/db.updateRole.txt +++ b/source/reference/method/db.updateRole.txt @@ -71,37 +71,17 @@ Definition * - Parameter - Type - - Description - * - ``rolename`` - - string - - The name of the :ref:`user-defined role ` to update. - - - * - ``update`` - - document - - A document containing the replacement data for the role. This data completely replaces the corresponding data for the role. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - update operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The ``update`` document specifies the fields to update and the new values. Each field in the ``update`` document is optional, but the diff --git a/source/reference/method/db.updateUser.txt b/source/reference/method/db.updateUser.txt index e02e71b8f2c..c521c961c31 100644 --- a/source/reference/method/db.updateUser.txt +++ b/source/reference/method/db.updateUser.txt @@ -64,39 +64,18 @@ Definition :widths: 20 20 80 * - Parameter - - Type - - Description - * - ``username`` - - string - - The name of the user to update. - - - * - ``update`` - - document - - A document containing the replacement data for the user. This data completely replaces the corresponding data for the user. - - - * - ``writeConcern`` - - document - - - Optional. The level of :doc:`write concern ` for the - update operation. The ``writeConcern`` document takes the same - fields as the :dbcommand:`getLastError` command. - - - - + - .. include:: /includes/fact-write-concern-spec-link.rst The ``update`` document specifies the fields to update and their new values. All fields in the ``update`` document are optional, diff --git a/source/reference/method/js-database.txt b/source/reference/method/js-database.txt index 1dae26ffebc..d72a5de93fb 100644 --- a/source/reference/method/js-database.txt +++ b/source/reference/method/js-database.txt @@ -78,14 +78,6 @@ Database Methods - Lists all collections and views in the current database. - * - :method:`db.getLastError()` - - - Checks and returns the status of the last operation. Wraps :dbcommand:`getLastError`. - - * - :method:`db.getLastErrorObj()` - - - Returns the status document for the last operation. Wraps :dbcommand:`getLastError`. - * - :method:`db.getLogComponents()` - Returns the log message verbosity levels. @@ -227,8 +219,6 @@ Database Methods /reference/method/db.getCollection /reference/method/db.getCollectionInfos /reference/method/db.getCollectionNames - /reference/method/db.getLastError - /reference/method/db.getLastErrorObj /reference/method/db.getLogComponents /reference/method/db.getMongo /reference/method/db.getName diff --git a/source/reference/privilege-actions.txt b/source/reference/privilege-actions.txt index 5591fb509fe..be41ed9e569 100644 --- a/source/reference/privilege-actions.txt +++ b/source/reference/privilege-actions.txt @@ -40,7 +40,7 @@ Query and Write Actions - :dbcommand:`filemd5` - :dbcommand:`find` - :dbcommand:`geoSearch` (*Removed in MongoDB 5.0*) - - :dbcommand:`getLastError` + - :dbcommand:`getLastError` (*Removed in MongoDB 5.1*) - :dbcommand:`getMore` - :dbcommand:`killCursors`, provided that the cursor is associated with a currently authenticated user. diff --git a/source/release-notes/1.8.txt b/source/release-notes/1.8.txt index 99f67488ced..6866b6d2ae2 100644 --- a/source/release-notes/1.8.txt +++ b/source/release-notes/1.8.txt @@ -312,7 +312,7 @@ Additional Changes and Enhancements - Improved :term:`replica set` connectivity for :binary:`~bin.mongos`. -- :dbcommand:`getLastError` improvements for :term:`sharding`. +- ``getLastError`` improvements for :term:`sharding`. 1.7.4 ````` diff --git a/source/release-notes/2.0.txt b/source/release-notes/2.0.txt index 4d278ad7e65..06c47a8c63d 100644 --- a/source/release-notes/2.0.txt +++ b/source/release-notes/2.0.txt @@ -312,10 +312,10 @@ Journaling Enhancements specifying your own group commit interval. The default settings do not change. -- A new :dbcommand:`{ getLastError: { j: true } } ` option is - available to wait for the group commit. The group commit will happen - sooner when a client is waiting on ``{j: true}``. If journaling is - disabled, ``{j: true}`` is a no-op. +- A new ``{ getLastError: { j: true } }`` option is available to wait + for the group commit. The group commit will happen sooner when a + client is waiting on ``{j: true}``. If journaling is disabled, + ``{j: true}`` is a no-op. New ``ContinueOnError`` Option for Bulk Insert ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -323,10 +323,10 @@ New ``ContinueOnError`` Option for Bulk Insert Set the ``continueOnError`` option for bulk inserts, in the :driver:`driver `, so that bulk insert will continue to insert any remaining documents even if an insert fails, as -is the case with duplicate key exceptions or network interruptions. The :dbcommand:`getLastError` +is the case with duplicate key exceptions or network interruptions. The ``getLastError`` command will report whether any inserts have failed, not just the last one. If multiple errors occur, the client will only receive the -most recent :dbcommand:`getLastError` results. +most recent ``getLastError`` results. .. include:: /includes/note-bulk-inserts-on-sharded-clusters.rst diff --git a/source/release-notes/2.6-compatibility.txt b/source/release-notes/2.6-compatibility.txt index 58c8335c842..8d9f9f0ad5e 100644 --- a/source/release-notes/2.6-compatibility.txt +++ b/source/release-notes/2.6-compatibility.txt @@ -168,11 +168,11 @@ Description :method:`db.collection.insert()`, :method:`db.collection.update()`, ``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 - ` whether run interactively in the - :binary:`~bin.mongo` shell or non-interactively in a script. In previous - versions, these methods exhibited a "fire-and-forget" behavior. + directly into the method rather than with a separate ``getLastError`` + command to provide :ref:`acknowledgement of writes ` whether + run interactively in the :binary:`~bin.mongo` shell or + non-interactively in a script. In previous versions, these methods + exhibited a "fire-and-forget" behavior. [#mongo-shell-gle-interactive]_ - Existing scripts for the :binary:`~bin.mongo` shell that used these @@ -182,7 +182,7 @@ Description - The write methods now return a :method:`WriteResult` object that contains the results of the operation, including any write errors and write concern errors, and obviates the need to call - :dbcommand:`getLastError` command to get the status of the results. + ``getLastError`` command to get the status of the results. See :method:`db.collection.insert()`, :method:`db.collection.update()`, ``db.collection.save()`` and :method:`db.collection.remove()` for details. @@ -194,10 +194,10 @@ Description .. [#mongo-shell-gle-interactive] In previous versions, when using the :binary:`~bin.mongo` shell interactively, the :binary:`~bin.mongo` shell automatically called the - :dbcommand:`getLastError` command after a write method to provide + ``getLastError`` command after a write method to provide acknowledgement of the write. Scripts, however, would observe "fire-and-forget" behavior in previous versions unless the scripts included an - **explicit** call to the :dbcommand:`getLastError` command after a + **explicit** call to the ``getLastError`` command after a write method. Solution diff --git a/source/release-notes/5.0-compatibility.txt b/source/release-notes/5.0-compatibility.txt index ab817161b1c..b6bbc404711 100644 --- a/source/release-notes/5.0-compatibility.txt +++ b/source/release-notes/5.0-compatibility.txt @@ -475,19 +475,14 @@ deprecated opcodes. The related commands and methods are also deprecated in MongoDB 5.0: -- :dbcommand:`getLastError` -- :method:`db.getLastError()` -- :method:`db.getLastErrorObj()` +- ``getLastError`` +- ``db.getLastError()`` +- ``db.getLastErrorObj()`` To ensure your driver uses the most up-to-date wire protocol, upgrade your driver to a 5.0-compatible version. -Any code explicitly using :dbcommand:`getLastError`, -:method:`db.getLastError()`, or :method:`db.getLastErrorObj()` -should instead use the CRUD API to issue the write with -the desired :doc:`write concern `. -Information about the success or failure of the write operation will be -provided directly by the driver as a return value. +.. include:: /includes/5.0-changes/fact-getLastError-alternatives.rst .. _5.0-compatibility-enabled: diff --git a/source/release-notes/5.1-compatibility.txt b/source/release-notes/5.1-compatibility.txt index 3b5f9434a74..0ac650d2337 100644 --- a/source/release-notes/5.1-compatibility.txt +++ b/source/release-notes/5.1-compatibility.txt @@ -43,12 +43,20 @@ Starting in MongoDB 5.1, these operators are removed: - :method:`cursor.returnKey()` * - $showDiskLoc - :method:`cursor.showRecordId()` + * - ``db.getLastError()`` + - See :ref:`legacy-op-codes-removed` + * - ``db.getLastErrorObj()`` + - See :ref:`legacy-op-codes-removed` + * - ``getLastError`` + - See :ref:`legacy-op-codes-removed` Removed Parameters ------------------ .. include:: /includes/5.1/removed-parameters.rst +.. include:: /includes/5.1/removed-shell-parameters.rst + Aggregation ----------- @@ -63,9 +71,6 @@ Removed Index Types Removed Metrics --------------- -Shell Changes -------------- - Replica Sets ------------ @@ -102,6 +107,69 @@ Starting in MongoDB 5.1 (and 5.0.4 and 4.4.10), the :query:`$mod` operator returns an error if the ``divisor`` or ``remainder`` values evaluate to certain values. See :ref:`$mod behavior `. +.. _legacy-op-codes-removed: + +Legacy Opcodes Removed +~~~~~~~~~~~~~~~~~~~~~~ + +MongoDB drivers have used :ref:`OP_MSG ` instead of +:ref:`OP_QUERY ` and the other legacy opcodes since +MongoDB v3.6. + +This release removes support for the following legacy opcodes: + +- :ref:`OP_INSERT ` +- :ref:`OP_DELETE ` +- :ref:`OP_UPDATE ` +- :ref:`OP_KILL_CURSORS ` +- :ref:`OP_GET_MORE ` +- :ref:`OP_QUERY ` + +To avoid disruption due to the removal of these op codes, please +upgrade your driver to the latest version. + +:binary:`mongod` will close the connection and will not respond to: + +- :ref:`OP_INSERT ` +- :ref:`OP_DELETE ` +- :ref:`OP_UPDATE ` +- :ref:`OP_KILL_CURSORS ` + +:binary:`mongod` will return an error for: + +- :ref:`OP_GET_MORE ` +- :ref:`OP_QUERY ` legacy find + +The :ref:`OP_QUERY ` RPC protocol may be used with the +following commands: + +- ``_isSelf`` +- ``authenticate`` +- ``buildinfo`` +- ``buildInfo`` +- ``hello`` +- ``ismaster`` +- ``isMaster`` +- ``saslContinue`` +- ``saslStart`` + +:ref:`OP_QUERY ` will return an error if it is used for +a find operation. All other commands will be rejected if issued as +:ref:`OP_QUERY `. + +If you attempt to connect to a MongoDB 3.4, or older, :binary:`mongod` +instance with a MongoDB 5.1, or newer, :binary:`~bin.mongo` shell, you +will receive an error message like the following: + +.. code-block:: javascript + :copyable: false + + // Reformated for clarity. The message appears on a single line. + + Connection handshake failed. Is your mongod 3.4 or older? + :: caused by :: network error while attempting to run command + 'isMaster' on host '127.0.0.1:27017' + Deprecations ------------ diff --git a/source/release-notes/drivers-write-concern.txt b/source/release-notes/drivers-write-concern.txt index d3fc758927d..d422b8061ff 100644 --- a/source/release-notes/drivers-write-concern.txt +++ b/source/release-notes/drivers-write-concern.txt @@ -48,15 +48,17 @@ drivers: Please migrate to the new ``MongoClient`` class expeditiously. -.. [#without-arguments] The drivers will call - :dbcommand:`getLastError` without arguments, which is logically - equivalent to the ``w: 1`` option; however, this operation allows - :term:`replica set` users to override the default write concern - with the - :rsconf:`settings.getLastErrorDefaults` - setting in the +.. [#without-arguments] The drivers will call ``getLastError`` without + arguments, which is logically equivalent to the ``w: 1`` option. + + However, this operation allows :term:`replica set` users to override + the default write concern with the + :rsconf:`settings.getLastErrorDefaults` setting in the :doc:`/reference/replica-configuration`. + ``getLastError`` is removed starting in MongoDB 5.1. See + :ref:`wc-specs` for alternatives. + .. _write-concern-change-releases: Releases diff --git a/source/tutorial/terminate-running-operations.txt b/source/tutorial/terminate-running-operations.txt index 517042dc71d..bcb20380cf9 100644 --- a/source/tutorial/terminate-running-operations.txt +++ b/source/tutorial/terminate-running-operations.txt @@ -62,15 +62,8 @@ time limit of 45 milliseconds for the operation: key: "city", maxTimeMS: 45 } ) -:method:`db.getLastError()` and :method:`db.getLastErrorObj()` will return -errors for interrupted options: - -.. code-block:: javascript - - { "n" : 0, - "connectionId" : 1, - "err" : "operation exceeded time limit", - "ok" : 1 } +Operations that reach ``maxTimeMS`` will return a ``MaxTimeMSExpired`` +error. ``killOp`` ~~~~~~~~~~