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

node-sql-query

v0.2.0

Published

Node.js query interface for Microsoft SQL Server databases.

Downloads

20

Readme

A Node.js query interface for Microsoft SQL Server

This repository contains a Node.js interface that can query and paginate results from Microsoft SQL Server databases.

It internally handles the connection establishment and the connection pools so that many queries can be executed simultaneously.

Installation

npm install node-sql-query

Usage

const nsq = require ( 'node-sql-query' )()
, connConfig = {
    "user": "sa",
    "password": "Sqlserver0",
    "server": "localhost\\SQLEXPRESS",
    "database": "vsegbas",
    "port": 55857,
    "requestTimeout": 600000
}

nsq.request ( 
  "SELECT getdate() FROM sys.tables"
  , connConfig
  , function ( recorset ) { console.log(recorset) }
)

nsq.dbq ({
      "columns": [
        "clientes.cli_id",
        "cli_apellido1",
        "cli_apellido2"
      ],
      "schemaSyntax": "polizas inner join clientes on polizas.cli_id=clientes.cli_id",
      "dbConnConfig": connConfig,
      "orderbyColumns": [
        "clientes.cli_id"
      ],
      "offset": 4,
      "pageSize": 4,
      "language": "spanish"
}, function ( recorset ) { 
    console.log(recorset) 
})

Methods

.request(sqlSyntax,connConfig,cb)

Executes a SQL command.

Parameters

  • sqlSyntax

    (string) (Required)

    The SQL command to pass to the database.

  • connConfig

    (object) (Required)

    An object with the connection parameters. Refer to node-mssql general configuration

  • cb

    (function) (Required)

    Callback function that will be called at the end of the request. The recorset (object) or the error will be passed as parameter.

.dbq(query,cb)

Executes a parametrized SELECT or INSERT or UPDATE or DELETE or Stored Procedure statement.

Parameters

  • query

    (object) (Required)

    An object with the following keys:

    • operation: (string) Posible values are: select, insert, update, delete, sp.
    • language: (string) Refer to SQL Server SET LANGUAGE command for the available options.
    • dbConnConfig: (object)(Required) An object with the connection parameters. Refer to node-mssql general configuration
    • columns: (array)(Required) An Array with the names of the columns.
    • schemaSyntax: (string)(Required)
    • whereSyntax: (string)

    Only available for select operation:

    • orderbyColumns: (array)
    • pageSize: (string)
    • offset: (string)

    Only available for insert or update operations:

    • values: (array) Must have the same length as columns. Values that will be assigned to each column.

    Only available for sp operation:

    • sp_name: (string) The name of the Stored Procedure followed by the parameters.

    The resultant SQL queries will be composed like this:

    SELECT

    SET LANGUAGE [language] SELECT [columns] FROM [schemaSyntax] WHERE [whereSyntax] ORDER BY [orderbyColumns]

    The pageSize (number of records per page) and offset (number of records to skip) parameters allows for paging the results.

    INSERT

    SET LANGUAGE [language] INSERT INTO [schemaSyntax] ( [columns] ) VALUES ( [values] )

    UPDATE

    SET LANGUAGE [language] UPDATE [schemaSyntax] SET ( [columns[0]] = [values[0]], [columns[1]] = [values[1]], ... ) WHERE [whereSyntax]

    DELETE

    SET LANGUAGE [language] DELETE [schemaSyntax] WHERE [whereSyntax]

    SP

    SET LANGUAGE [language] EXEC [sp_name]

  • cb

    (function) (Required)

    Callback function that will be called at the end of the request. The recorset (object) or the error will be passed as parameter.