Docs: ReadTheDocs
- Download and install CouchDB following the docs.
- Download and install latest PSCouchDB module by copying it under
%Windir%\System32\WindowsPowerShell\v1.0\Modules
for all users or under%UserProfile%\Documents\WindowsPowerShell\Modules
for the current user or install through PowershellGallery.
Note
This module is not signed. Before import or execute cmdlet on this module, see about_signing session. To skip this part and continue, run Set-ExecutionPolicy -ExecutionPolicy Unrestricted
[!WARNING]
If you using CouchDB version 2, use the PSCouchDB 1.X version; if instead you are using CouchDB version 3 or 4, use the PSCouchDB version 2.X
- Now, configure database mode, in single node (cluster of one single node) or cluster, run this cmdlet:
# Single node cluster
Enable-CouchDBCluster -SingleNode -Authorization "admin:password"
# Cluster (with three node)
Enable-CouchDBCluster -Authorization "admin:password"
For more details, see the docs.
- Now, open powershell and create a first personal database:
New-CouchDBDatabase -Database test -Authorization "admin:password"
- Create a sample document for
test
database:
$Data = '{
"name": "Arthur Dent",
"planet": "Heart"
}'
New-CouchDBDocument -Database test -Document "Hitchhikers" -Data $Data -Authorization "admin:password"
- Add attachment file in our docuemnt:
$rev = (Get-CouchDBDocument -Database test -Document "Hitchhikers")._rev
"Ultimate Question of Life, the Universe and Everything" | Out-File C:\file.txt
Add-CouchDBAttachment -Database test -Document "Hitchhikers" -revision $rev -Attachment C:\file.txt -Authorization "admin:password"
- Finally, get a document:
Get-CouchDBAttachment -Database test -Document "Hitchhikers" -Attachment file.txt
These are just some of the operations you can do with this CLI. PSCouchDB supports all API of CouchDB server. If you want to find out more, follow the docs.
Before test this module, install latest version of CouchDB server and latest installation of Pester module.
Warning
Test this module in testing enviroment ONLY.
git clone "https://github.com/MatteoGuadrini/PSCouchDB.git"
cd "PSCouchDB/PSCouchDB/tests"
foreach ($f in (Get-ChildItem $PWD)) {
& pwsh $f.FullName # use powershell before 6.X
}
For other operation, for more details and for learning all cmdlets and possibilities, see the docs.
If you want to have an overview of the module, do this:
help about_pscouchdb
Search for the cmdlets using a keyword pattern and then view the help:
Search-CouchDBHelp -Pattern Database | foreach {Get-Help $_.Name}
or see docs. For a little demonstration, see here
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.