- 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.
dbHashis useful to compare databases acrossmongodinstances, such as mirrored config servers for sharded clusters or members of replica sets.dbHashhas the following syntax:Field Type Description dbHashAny type The command to run. Specify any value. collectionsarray 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.