diff --git a/source/reference/command/listDatabases.txt b/source/reference/command/listDatabases.txt index fee4927d006..2c3636ed65a 100644 --- a/source/reference/command/listDatabases.txt +++ b/source/reference/command/listDatabases.txt @@ -101,28 +101,6 @@ Definition .. versionadded:: 4.4 - -Output ------- - -:dbcommand:`listDatabases` returns a document that contains: - -- A field named ``databases`` whose value is an array of documents, one - document for each database. Each document contains: - - - A ``name`` field with the database name. - - - A ``sizeOnDisk`` field with the total size of the database files on - disk in bytes. - - - An ``empty`` field specifying whether the database has any data. - - - For sharded clusters, a ``shards`` field that includes the shard - and the size in bytes of the database on disk for each shard. - -- A field named ``totalSize`` whose value is the sum of all the - ``sizeOnDisk`` fields in bytes. - .. _listDatabases-behavior: Behavior @@ -130,8 +108,7 @@ Behavior When :doc:`authentication ` is enabled: -.. note:: show dbs - +.. note:: For :binary:`~bin.mongo` shell version 4.0.6+ connected to earlier versions of MongoDB deployment (e.g. 3.6.10), @@ -238,6 +215,7 @@ The following is an example of a :dbcommand:`listDatabases` result: } ], "totalSize" : 251658240, + "totalSizeMb" : 251, "ok" : 1 } @@ -290,6 +268,8 @@ name matches the specified :query:`regular expression <$regex>`: db.adminCommand( { listDatabases: 1, filter: { "name": /^rep/ } } ) +.. _listDatabases-sharded-clusters: + Sharded Clusters ~~~~~~~~~~~~~~~~ @@ -345,9 +325,66 @@ For example: "ok" : 1 } -.. seealso:: +.. seealso:: :doc:`/tutorial/use-database-commands`. + +.. |checkmark| unicode:: U+2713 + +Output +------ - :doc:`/tutorial/use-database-commands`. +.. data:: listDatabases.databases + *Type: Array* -.. |checkmark| unicode:: U+2713 + Array of documents, each containing information on a single + database. + +.. data:: listDatabases.databases.name + + *Type: String* + + Name of the database. + +.. data:: listDatabases.databases.sizeOnDisk + + *Type: Integer* + + Total size of the database files on disk, expressed in bytes. + +.. data:: listDatabases.databases.empty + + *Type: Boolean* + + Specifies whether the database is empty. + +.. data:: listDatabases.databases.shards + + *Type: Document* + + Each element in the ``shards`` document consists of a field whose key + gives the name of a collection on that shard, and whose value + represents the collection's size in bytes. + + ``shards`` only appears in the output if ``nameOnly: false``. + + See :ref:`Sharded Clusters ` + for details. + +.. data:: listDatabases.totalSize + + *Type: Integer* + + Sum of all the ``sizeOnDisk`` fields in bytes. + +.. data:: listDatabases.totalSizeMb + + *Type: Integer* + + Sum of all the ``sizeOnDisk`` fields, expressed in megabytes. + +.. data:: listDatabases.ok + + *Type: Integer* + + Return value for the command. A value of ``1`` indicates + success. diff --git a/source/release-notes/5.0-compatibility.txt b/source/release-notes/5.0-compatibility.txt index 482e239c77e..57bd36d71f8 100644 --- a/source/release-notes/5.0-compatibility.txt +++ b/source/release-notes/5.0-compatibility.txt @@ -131,6 +131,66 @@ operand expression ( ``{ }`` ): An empty update results in no changes and no :term:`oplog` entry is created (meaning that the operation is a no-op). +``listDatabases`` Output Changes +-------------------------------- + +Starting in MongoDB 5.0, output from the :dbcommand:`listDatabases` +command running against a :binary:`~bin.mongod` is more consistent with +output from :dbcommand:`listDatabases` running against a +:binary:`~bin.mongos`. + +The following table shows the differences in data types for +:dbcommand:`listDatabases` output fields between MongoDB 5.0 and earlier +versions. Only fields which differ between 5.0 and earlier versions are +listed. + +.. list-table:: + :header-rows: 1 + :widths: 30 30 30 30 + + * - Field + + - Type in MongoDB 5.0 + + - Type in MongoDB 4.4 and earlier (``mongod``) + + - Type in MongoDB 4.4 and earlier (``mongos``) + + * - ``sizeOnDisk`` + + - integer + + - double + + - integer + + * - ``totalSize`` + + - integer + + - double + + - integer + + * - ``totalSizeMb`` + + - integer + + - not present (see below) + + - integer + +The output from :dbcommand:`listDatabases` now includes the +``totalSizeMb`` field when run against either a :binary:`~bin.mongos` or +a :binary:`~bin.mongod`. In MongoDB 4.4 and earlier, ``totalSizeMb`` +only appears when run against :binary:`~bin.mongos`. ``totalSizeMb`` is +the sum of the ``sizeOnDisk`` fields, expressed in megabytes. + +When run against :binary:`~bin.mongos`, the ``shards`` field in the +:dbcommand:`listDatabases` output contains a field-value pair for each +collection on a particular shard. Size values in the ``shards`` field +are expressed as integers. + General Changes ---------------