apache / nano

Nano is now part of Apache CouchDB. Repo moved to https://GitHub.com/apache/couchdb-nano
https://github.com/apache/couchdb-nano
Other
1.13k stars 157 forks source link

piping views #285

Closed fhahne closed 9 years ago

fhahne commented 9 years ago

I may be completely off on this, but essentially I am trying to pipe the results of a view on to a stream. Using the example code from the docs, here is what I do:

alice.view('characters', 'crazy_ones', someKeys).pipe(fs.createWriteStream('/tmp/mydata.json'))

I expected to see the filtered results of that view in /tmp/mydata.json, but instead I get the full view. Executing the same call with a callback handler to write out the data works. Is streaming of views not supposed to work like this?

fhahne commented 9 years ago

Never mind, I found the issue. I had two consecutive calls to view with the same parameters object, and it seems like the original object gets modified by the view call, essentially kicking out the key property. A bit of an unexpected side effect. You may want to consider creating a clone of the parameters object before modifying.