문제

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