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 ?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top