Skip to content

Write only databases

Benoit Chesneau edited this page Jun 25, 2013 · 1 revision

Write-only or Dropbox databases are databases only accepting write but can be read by selected users. Only rcouch' admins or dropbox members can read documents that have been dropped in a dropbox database.

To mark a database as a Drop Box, add the property {"dropbox": true} to the security object.

Dropbox members are admins (global or db admins) and users sets in the dropbox_members property:

{"dropbox_members": {"names": [], "roles": []}}

Example of usage:

$ curl -XPUT admin:test@127.0.0.1:5984/testdb
{"ok":true}
$ curl -XPUT 127.0.0.1:5984/testdb/test -d'{}'
{"ok":true,"id":"test","rev":"1-967a00dff5e02add41819138abb3284d"}
$ curl -XPUT 127.0.0.1:5984/testdb/test1 -d'{}'
{"ok":true,"id":"test1","rev":"1-967a00dff5e02add41819138abb3284d"}
$ curl -XGET 127.0.0.1:5984/testdb/_all_docs
{"total_rows":2,"offset":0,"rows":[
{"id":"test","key":"test","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
{"id":"test1","key":"test1","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}]}
$ curl -XGET 127.0.0.1:5984/testdb/test1
{"_id":"test1","_rev":"1-967a00dff5e02add41819138abb3284d"}
$ curl -XPUT admin:test@127.0.0.1:5984/testdb/_security -d'{"dropbox": true}'
{"ok":true}
$ curl -XGET 127.0.0.1:5984/testdb/test1
{"error":"forbidden","reason":"Only administrators can view docs in a dropbox database."}
$ curl -XGET 127.0.0.1:5984/testdb/_all_docs
{"error":"forbidden","reason":"Only admins can access _all docs"}
$ curl -XPUT 127.0.0.1:5984/testdb/test2 -d'{}'
{"ok":true,"id":"test2","rev":"1-967a00dff5e02add41819138abb3284d"}
$ curl -XGET 127.0.0.1:5984/testdb/test2
{"error":"forbidden","reason":"Only administrators can view docs in a dropbox database."}
$ curl -XGET admin:test@127.0.0.1:5984/testdb/_all_docs
{"total_rows":3,"offset":0,"rows":[
{"id":"test","key":"test","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
{"id":"test1","key":"test1","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}},
{"id":"test2","key":"test2","value":{"rev":"1-967a00dff5e02add41819138abb3284d"}}
]}