map - CouchDB View with 2 Keys -


i looking general solution problem couchdb views.

for example, have view result this:

{"total_rows":4,"offset":0,"rows":[ {"id":"1","key":["imported","1"],"value":null}, {"id":"2","key":["imported","2"],"value":null}, {"id":"3","key":["imported","3"],"value":null}, {"id":"4","key":["mapped","4"],"value":null}, {"id":"5,"key":["mapped","5"],"value":null} ] 

1) if want select "imported" documents use this:

view?startkey=["imported"]&endkey=["imported",{}] 

2) if want select imported documents higher id 2:

view?startkey=["imported",2]&endkey=["imported",{}] 

3) if want select imported documents id between 2 , 4:

view?startkey=["imported",2]&endkey=["imported",4] 

my questtion is: how can select rows id between 2 , 4?

i ran same problem little while ago i'll explain solution. inside of map function can have multiple emit() calls. map function in case might like:

function(doc) {   emit([doc.number, doc.category], null);   emit([doc.category, doc.number], null); } 

you can use ?include_docs=true documents of queries. query rows 2 4 be

view?startkey=[2]&endkey=[4,{}] 

you can view rules sorting @ couchdb view collation


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -