npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mssqlstream

v0.0.3

Published

fetch all the data from mssql with pause and resume

Readme

MSSQLStream.js

Build Status

back-pressure in node-mssql

mssql issure Back pressure? #67

when use node-mssql to traverse a table of MSSQL Server database, you may face the back-pressure problem if data is very big. node-mssql does not support the pause and resume in stream now.

why mssql-stream

use mssql-stream you can fetch all the data row by row, with pause and resume. when the row is coming, pause the stream, after comsume the row, resume the stream in a callback or resume the stream direct.

how to use mssql-stream

  1. it is not a real stream, and there are about 1000 rows cached.
  2. the table must have a (unique and int) field.
  3. mssql-stream is only support fetch all the data from table, 'SELECT WHERE' or other queries is not supported.

what is in mssql-stream

  1. get the range of (unique and int) field.
  2. fetch first 1000 rows by specific the (unique and int) field.
  3. after these 1000 rows consumed, fetch next 1000 rows
  4. until no more rows left, done.

API

Constructor

/**
 * @param {[Object]} dbConfig config for node-mssql connection   
  {
      user: 'youruser',
      password: 'yourpass',
      port: 1433,
      server: '192.168.1.1',
      database: 'yourdb'
   }
 * @param {[Object]} tableConfig specific the table and (unique and int) field name
   {
    name: '[dbo].[test_table]',
    uniqueColumn: 'myid'
   }
 */
var mssqlStream = new MSSQLStream(dbConfig, tableConfig);

Methods

mssqlStream.pause()

pause the stream, MSSQLStream will not return new rows, until calling the resume().

mssqlStream.resume()

resume the stream

Events

'row'

return a row

mssqlStream.on('row', function(row) {
  //To-Do  
});

'error'

return error info

mssqlStream.on('error', function(errorInfo) {
    //To-Do
})

'end'

all rows has been fetched

mssqlStream.on('end', function() {
  //To-Do
});

Use

var MSSQLStream = require('mssql-stream');

var dbConfig = {
  user: 'youruser',
  password: 'yourpass',
  port: 1433,
  server: '192.168.1.1',
  database: 'yourdb'
};


var tableConfig = {
  // specific the table 
  name: '[dbo].[test_table]',
  // specific the (unique and int) field 
  uniqueColumn: 'myid'
};


var mssqlStream = new MSSQLStream(dbConfig, tableConfig);

mssqlStream.on('error', function(err) {
  console.log("err:" + err);
});

mssqlStream.on('row', function(row) {
  console.log(row[tableConfig.uniqueColumn]);

  //pause the stream
  mssqlStream.pause();

  //use setTimeout to simulate the data processing 
  setTimeout(function() {
    console.log('in timeout:' + row[tableConfig.uniqueColumn]);

    //done, resume the stream
    mssqlStream.resume();
  }, 100);
});

mssqlStream.on('end', function(info) {
  console.log("fetch end");
  console.log('info:' + info);
});

Test

Run npm install Run npm test

License

WTFPL License.