Question

I'm using couchDB and I have a problem trying to get the information that I want. Here's an example of my keys

[1,"Demo","March"]
[1,"Demo","May"]
[1, "No Demo", "May"]

I want to get all the keys that have "Demo" in the middle, I'm trying this:

http://localhost:PORT/database/_design/demo/_view/demoview?starkey=[{},"Demo",{}]&endkey=[{},"Demo",{}]

But I'm getting all the records, any idea?

Was it helpful?

Solution

You can't, sorry. you can only ask for key ranges based on prefix, you can get the values between [1, ...] and [999, "foo"], but you can't possibly write a query that will give you the values between [..., "foo"] and [..., "bar"]

For that, you need to write another view, one where the "demo" fragment appears first in the resulting keys.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top