The Database endpoint provides an interface to an entire database with in CouchDB. These are database-level, rather than document-level requests.

Test a database

To verify the existence of a database.

Test-CouchDBDatabase -Database test

Read a database

Gets information about the specified database.

Get-CouchDBDatabase -Database test

To get alist of all databases, run this:


Create a database

Creates a new database.

New-CouchDBDatabase -Database test -Authorization "admin:password"


If we repeat the same request to CouchDB, it will response with 412 since the database already exists. If an invalid database name is supplied, CouchDB returns response with 400

Remove a database

Deletes the specified database, and all the documents and attachments contained within it.

Remove-CouchDBDatabase -Database test -Authorization "admin:password"

Copy a database

Create a new database test_copy by copying it from test database.

Copy-CouchDBDatabase -Database test -Destination test_copy -Authorization "admin:password"


Mango is a declarative JSON querying language for CouchDB databases. Mango wraps several index types, starting with the Primary Index out-of-the-box.

Get a index

To get list of index present on a database.

Get-CouchDBIndex -Database test

Create a new index

Create a new index on a database.

New-CouchDBIndex -Database test -Name test-index -Fields name,surname -Authorization "admin:password"

Remove a index

Remove an existing index.

$idx = Get-CouchDBIndex -Database test
Remove-CouchDBIndex -Database test -DesignDoc $idx.indexes.ddoc[1] -Name $[1] -Authorization "admin:password"


Get a list of database shards. Each shard will have its internal database range, and the nodes on which replicas of those shards are stored.

Get shards

Get a list a database shards.

Get-CouchDBDatabaseShards -Database test

Sync shards

For the given database, force-starts internal shard synchronization for all replicas of all database shards.

Sync-CouchDBDatabaseShards -Database test -Authorization "admin:password"


To get a sorted list of changes made to documents in the database, in time order of application, can be obtained from the database’s _changes resource.

Get-CouchDBDatabaseChanges -Database test


Request compaction of the specified database. Compaction can only be requested on an individual database; you cannot compact all the databases for a CouchDB instance. The compaction process runs as a background process.

Compress-CouchDBDatabase -Database test -Authorization "admin:password"

Write a commit

Commits any recent changes to the specified database to disk.

Write-CouchDBFullCommit -Database test -Authorization "admin:password"

Clear view

Removes view index files that are no longer required by CouchDB as a result of changed views within design documents.

Clear-CouchDBView -Database test -Authorization "admin:password"

Get purged info limit

Gets the current purged_infos_limit (purged documents limit) setting, the maximum number of historical purges (purged document Ids with their revisions) that can be stored in the database.

Get-CouchDBDatabasePurgedLimit -Database test

Set purged info limit

Set the current purged_infos_limit (purged documents limit) setting.

Set-CouchDBDatabasePurgedLimit -Database test -Limit 1500 -Authorization "admin:password"


Working with database revisions.

Get missing revisions

Get a list of document revisions, returns the document revisions that do not exist in the database.

Get-CouchDBMissingRevision -Database test -Document "Hitchhikers" -Revision 2-7051cbe5c8faecd085a3fa619e6e6337,3-825cb35de44c433bfb2df415563a19de

Get revision difference

Given a set of document/revision IDs, returns the subset of those that do not correspond to revisions stored in the database.

Get-CouchDBRevisionDifference -Database test -Document "Hitchhikers" -Revision 2-7051cbe5c8faecd085a3fa619e6e6337,3-825cb35de44c433bfb2df415563a19de

Get revision limit

Gets the current revs_limit (revision limit) setting.

Get-CouchDBRevisionLimit -Database test

Set revision limit

Sets the maximum number of document revisions that will be tracked by CouchDB.

Set-CouchDBRevisionLimit -Database test -Limit 1500 -Authorization "admin:password"

Export and import databases

One of the most common practices for perform backup a database is to export it. On the other hand, to restore a database, just import it.


For export a database in a json file format.


If you do not specify the path and file name, a JSON file will be saved in UTF8 format in the current path ($pwd) with this name: name-of-database_t-i-m-e_s_t_a_m_p.json.

Export-CouchDBDatabase -Database test


For import or restore a database from JSON file.

Import-CouchDBDatabase -Database test -Path test_01-25-2019_00_01_00.json

And this, for create a new database from JSON file.

Import-CouchDBDatabase -Database test_restored -Path test_01-25-2019_00_01_00.json -RemoveRevision