It cannot be done due to the nature of views and the way couchdb does map-reduce. View output should be deterministic and as such cannot depend on query-time parameters. This is what allows the index to be build incrementally and the reason why a _list function runs through the whole result set every time you query it but views can be retrieved with ?stale=ok and aren't re-run for every request.
On Mon, Dec 6, 2010 at 09:28, Wordit Ltd <[email protected]> wrote: > Can parameters be passed to views? I know you can use them in updaters. > I hoped this would work, but it did not: > > function(doc, req) { > var myparam = req.query.myparam; > ... > > URL: .../view_name?myparam="foo" > > > I need to pass two parameters to a for loop which is pulling data from > an array/list. > I have data stored in the array "words". > > function(doc) { > for (i=0; i < doc.words.length;i++) { > emit(i, doc.words[i]); > } > } > > This outputs ALL items in the array. I want to pass in A and B as > params to the for loop. > Can this be done, or is there another way to achieve it? > > Thanks, > > Marcus >
