문제

I use CouchDB 1.5.0 and noticed a strange thing:

When I query some API action, for example:

curl -X GET "http://localhost:5984/mydb/_changes?limit=1"

I get the same result with limit=1 and with limit=0 and with limit=-55. In all cases is a one row from the start of list.

Although, PostgreSQL returns:

  • Zero rows when LIMIT 0
  • Message ERROR: LIMIT must not be negative when LIMIT -55

My question is mainly concerned with the API design. I would like to know your opinions.

It's a flaw or maybe it's good/acceptable practice?

도움이 되었습니까?

해결책

This is how the _changes api is designed. If you do not specify the type of feed i.e long-poll, continuous etc the default is to return a list of all the changes in a single results array.

If you want a row by row result of the changes in the database specify the type of feed in the url like so

curl -X GET "http://localhost:5984/mydb/_changes?feed=continuous"

Another point to note that in the _changes api using 0 has the same effect as using 1 in limit parameter.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top