- Reference >
- Database Commands >
- Diagnostic Commands >
- dbHash
dbHash¶
On this page
Definition¶
-
dbHash
¶ Returns the hash values of the collections in a database and an MD5 value for the list of collections.
dbHash
is useful to compare databases acrossmongod
instances, such as mirrored config servers for sharded clusters or members of replica sets.dbHash
has the following syntax:Field Type Description dbHash
Any type The command to run. Specify any value. collections
array Optional. An array of collection names.
Either specify the collections for which to return the hash values, or omit or specify an empty array to return the hash values for all collections in the database.
Behavior¶
If a collection in the collections
array is non-existent,
dbHash
does not return a hash value for that collection.
Examples¶
Return Hash Values for All Collections in a Database¶
The following example returns the hash value for all collections in the
database test
:
The operation returns the following document:
Return Hash Values for Specified Collections in a Database¶
The following example returns the hash value for the collections foo
and bar
in the database test
:
The operation returns the following document:
Note
The md5
is the aggregate hash value
of the specified collections.