Search code examples
couchdbcouchdb-futon

How to create Manual ID CouchDB


I have a Json file as such :

{
   "_id":"03f8dcb28c93ec4b6c39d6bdf45bcf57",
   "api_rev":"1.0",
   "type":"router"
}

The _id identifies a particular entity thus, i will not like to go for the auto generated one. When i push to couchdb i get :

{"error":"POST uses auto generated id"}

How may i force the id i provide as the actual id without using the auto generated type ?


Solution

  • You can do a PUT request instead to create the document with PUT /database/03f8dcb28c93ec4b6c39d6bdf45bcf57 and have the body as:

    {
       "api_rev":"1.0",
       "type":"router"
    }
    

    That will create a new document with that id.