Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add design documents (beginning with "_") in CouchDB

Tags:

couchdb

When I try to add design documents (beginning with "_") I get an error "Only reserved document ids may start with underscore." How can I add a design document?

like image 571
Andrew Campoli Avatar asked Nov 16 '25 17:11

Andrew Campoli


1 Answers

According to the Definitive Guide, a design document like this one:

{
  "_id" : "_design/example",
  "views" : {
    "foo" : {
      "map" : "function(doc){ emit(doc._id, doc._rev)}"
    }
  }
}

can be added to the database named basic with a curl command like this:

curl -X PUT http://127.0.0.1:5984/basic/_design/example --data-binary @mydesign.json

Personally, I find it much easier to use CouchApp to add and manage design documents. This section of the Definitive Guide describes how to install and use it.

like image 152
lambmj Avatar answered Nov 19 '25 10:11

lambmj