CouchDB - ilya-khadykin/notes-outdated GitHub Wiki
TO DO:
- look through wiki - https://wiki.apache.org/couchdb/
Web interface (Futon user interface) is available by default: http://127.0.0.1:5984/_utils/
_id
hash is automatically generated and typically shouldn't be changed
_rev
hash is automatically and it changes if there was a change
call | comment |
---|---|
http://127.0.0.1:5984/_all_dbs |
lists all available dbs |
http://127.0.0.1:5984/restaurant |
shows db related info for restaurant db |
http://127.0.0.1:5984/restaurant/_all_docs |
lists all available docs in restaurant db |
http://127.0.0.1:5984/restaurant/75bf14595624b824e313bf7f17000bba |
returns document with specified id |
You can query CouchDB using JavaScript by writing required map function. Go to http://127.0.0.1:5984/_utils/YOUR_DATABASE_NAME.html?restaurant/_temp_view and write your function:
function(doc) {
emit(doc.name, doc.content);
}
We can create custom views based on our map()
function and save them for later use
View can be further sorted using HTTP GET ?key=""
param, for example?key="Delivery"
CouchDB can also serve binary files (images for example). You can add files to your documents using **attachments **feature.
Q: Where to find actual files?
A: They are stored in var\lib\couchdb
in Windows:
C:\Program Files (x86)\Apache Software Foundation\CouchDB\var\lib\couchdb # windows
Q: How to secure your databases?
A: You should create an admin user and change configuration option require valid user
to true. After that you have to supply user an password for query data: http://admin:[email protected]:5984/restaurant/_all_docs