CouchDB

sudo snap install couchdb

Configuration
/etc/couchdb/default.ini
bind_address = 0.0.0.0
allow_jsonp = true

How to restart server
# systemctl restart couchdb
Client
curl -X GET --noproxy localhost http://localhost:5984/
curl -X PUT --noproxy localhost http://localhost:5984/baseball
curl -X PUT --noproxy localhost http://localhost:5984/basketball
curl -X GET --noproxy localhost http://localhost:5984/_all_dbs

curl -X GET --noproxy localhost http://localhost:5984/baseball/_all_docs
curl -X GET --noproxy localhost http://localhost:5984/baseball/_all_docs?include_docs=true
curl -X DELETE --noproxy localhost http://localhost:5984/baseball

DELETE
curl --noproxy localhost -X DELETE http://localhost:5984/nagano/t2025?rev=1-3aa6cd05c8585e6c3bc5c559dff1e967
$ sudo couchdb
Apache CouchDB 1.0.1 (LogLevel=info) is starting.
Apache CouchDB has started. Time to relax.
[info] [<0.33.0>] Apache CouchDB has started on http://0.0.0.0:5984/
[info] [<0.104.0>] 127.0.0.1 - - 'GET' / 200
[info] [<0.173.0>] 127.0.1.1 - - 'GET' / 200
[info] [<0.182.0>] 172.20.249.5 - - 'GET' / 200
[info] [<0.182.0>] 172.20.249.5 - - 'GET' / 200
[info] [<0.250.0>] 172.20.179.177 - - 'GET' / 200
Bash

curl -X DELETE http://localhost:5984/my-db
curl -X PUT http://localhost:5984/my-db
curl -X PUT http://localhost:5984/my-db/cities -d@cities.json
PHP

php5-curl

Python

# pacman -S python-pycurl

# apt install python-pycurl

Perl

libwww-curl-perl

Ruby

ii  ruby-rest-client       1.6.7-4    all     simple REST client for Ruby
Arch Linux
$ yay -S ruby-rest-client

Ocaml

libcurl-ocaml-dev

Lua

liblua5.1-socket2

Tcl

tclcurl

C++

libcurl4-openssl-dev

node.js

felixge-node-couchdb-713605b.tar.gz

Java

libcommons-httpclient-java

couchapp

CouchApp.org: Getting Started


$ curl --noproxy localhost http://localhost:5984
{"couchdb":"Welcome","uuid":"583ff8276ddb111f07d1c15f8353fcee","version":"1.6.1","vendor":{"version":"1.6.1","name":"The Apache Software Foundation"}}

View の作成方法
View の例 (ex06.json)
{ 
   "language"  : "javascript",
   "views"     : {
      "ex06"    : { 
         "map" : "function(doc){ 
               emit(doc.artist, doc.title);
         }" 
      }
  }
}
View の登録
curl -X PUT http://localhost:5984/quotes/_design/ex06 -d@ex06.json
View の実行
curl -X GET http://localhost:5984/albums/_design/ex06/_view/ex06

key で検索
curl -X GET http://localhost:5984/albums/_design/ex06/_view/ex06?key=\"Chopin\"


Replication

$ curl --noproxy server_remote -X PUT http://server_remote:5984/nagano

$ curl --noproxy server_remote -H "Content-Type: application/json" -X POST 'http://localhost:5984/_replicate' -d'{"source":"nagano","target":"http://server_remote:5984/nagano"}'


Ubuntu 15.04
# couchdb -b

圧縮

#
curl --noproxy localhost -H "Content-Type: application/json" -X POST http://localhost:5984/my_database/_compact
#
curl --noproxy localhost -H "Content-Type: application/json" -X POST http://localhost:5984/my_database/_view_cleanup
result_aa

outarea_aa
outarea_bb
outarea_cc
outarea_dd
outarea_ee
outarea_ff
outarea_gg
outarea_hh

Return

May/09/2023 AM 08:15