View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

.stream( criteria )


This method uses a node write stream to pipe model data as it is retrieved without first having to buffer all of the results to memory.



Description Accepted Data Types Required ?
1 Find Criteria {},[{}], string, int Yes
2 Custom Write/End Methods {} No


Description Possible Data Types
1 Error Error
2 Stream of Records stream

Example Usage


module.exports = {

  testStream: function(req, res){

    if (req.param('startStream') && req.isSocket){

        var getSocket = req.socket;

        // Start the stream.  Pipe it to sockets.{name:'Walter'}).pipe(getSocket.emit);

    } else {





<script type="text/javascript">
window.onload = function startListening(){
      console.log( + ' number ' + + ' has joined the party');

<div class="addButton" onClick="socket.get('/users/testStream/', {startStream:true})">Stream all the Users!</div>


This method is useful for piping data from VERY large models straight to res. You can also pipe it other places. See the node stream docs for more info. Only the mongo, mysql, and posgresql adapters support this method. This won't work with the disk adapter. Any string arguments passed must be the ID of the record.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.


We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book