In this exercise you have to intall CouchDB and interact with it using CouchDB's RESTful Web API.
- Install CouchDB on your computer.
- Visit Fauxton (=CouchDB's web-based administration tool) at http://localhost:5984/_utils/#setup and choose Configure a Single Node
- Enter username and password
- Use 127.0.0.1 as the IP address (=CouchDB not available on the network, just on your computer)
- Accept the suggested port (e.g. 5984)
- Install CouchDB as described above.
- Use any REST client (e.g. Postman, Visual Studio Code) to execute the operations below
GET http://127.0.0.1:5984/ HTTP/1.1
PUT http://127.0.0.1:5984/my_first_db HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
- Note Basic Authentication
GET http://127.0.0.1:5984/my_first_db HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
POST http://127.0.0.1:5984/my_first_db HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=
{
"schoolName": "HTL Perg",
"location": "Perg",
"country": "Austria"
}
POST http://127.0.0.1:5984/my_first_db/_find HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=
{
"selector": {
"country": { "$eq": "Austria" }
},
"fields": [ "_id", "_rev", "schoolName" ]
}
DELETE http://127.0.0.1:5984/my_first_db/6fd2474efa515a3a84fe2e0496000387?rev=1-c03973c2778ca77eef6b2f64a069df03 HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
DELETE http://127.0.0.1:5984/my_first_db HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
- To get the Authorization header, you have to Base64-encode username:password
- Consider Visual Studio Code plugin vscode-base64
- Consider online encoder. Never use online encoder with real-life passwords!!
- Read details about CouchDB's REST API
- Build a web UI (HTML, JavaScript, fetch API) for manipulating documents in CouchDB