LearnBoost/mongoose — pull request #1242 by seykron (2012-12-10 01:07:49+00:00)
Title: Fixed bug in query streaming result.

Steps to reproduce:
1) Create a collection Things.
2) Perform a query to list Things.
3) Redirect output to http.ServerResponse.

Expected result:
Query results are streamed to the response.

Actual results:
A type error is thrown by http.ServerResponse.

```
TypeError: first argument must be a string or Buffer
at ServerResponse.OutgoingMessage.write (http.js:715:11)
```

Fix details:
It seems that ServerResponse is expecting either a Buffer or a String, and
QueryStream is sending an object instead. Changed QueryStream to transform
the model instance to String via JSON.stringify.

Code to reproduce:
```
/*
... Create a collection and save some kitties ...
*/
var server = require("http").createServer();
server.on("request", function (req, res) {
Kitten.find({}).stream().pipe(res);
});
```