GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - roncli/node-database: A simple reusable class to query a MS SQL Server database.

BranchesTags
Open more actions menu

Latest commit

 

History

632 Commits
632 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
tests
tests
 
 
types
types
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
eslint.config.mjs
eslint.config.mjs
 
 
index.d.ts
index.d.ts
 
 
index.js
index.js
 
 
jest.config.js
jest.config.js
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

node-database

A simple reusable class to query a MS SQL Server database. This uses the mssql package to access SQL Server.

Installing

Since this is largely used for personal projects, this is not an npm package. Nevertheless, you may still install this by adding the following to your package.json:

{
    "dependencies": {
        "@roncli/node-database": "roncli/node-database#v1.2.15"
    }
}

Usage

const Db = require("@roncli/node-database");

const db = new Db({
    server: "ms.sql.server.com",
    port: 1433,
    user: "my_user_name",
    password: "my_password",
    database: "my_database",
    pool: {
        max: 50,
        min: 0,
        idleTimeoutMillis: 30000
    },
    options: {
        trustServerCertificate: true
    }
});

try {
    const data = await db.query(
        "SELECT col1, col2 FROM myTable WHERE col3 = @col3",
        {col3: {type: Db.INT, value: 123}}
    );

    if (data && data.recordsets && data.recordsets[0]) {
        data.recordsets[0].forEach((row) => {
            console.log(`Col1: ${row.col1}, Col2: ${row.col2}`);
        });
    }
} catch (err) {
    console.log("There was an error connecting to the database.");
    console.log(err);
}

See the mssql package for more examples of settings and how to query using the library.

Version history

v1.2.16 - 3/29/2025

  • Add jest unit tests.
  • Package updates.

v1.2.15 - 9/14/2023

  • Package updates.

v1.2.14 - 8/8/2023

  • Package updates.

v1.2.13 - 5/17/2023

  • Package updates.

v1.2.12 - 10/1/2022

  • Package updates.

v1.2.11 - 8/9/2022

  • Package updates.

v1.2.10 - 5/30/2022

  • Package updates.

v1.2.9 - 5/21/2022

  • Package updates.

v1.2.8 - 5/4/2022

  • Package updates.

v1.2.7 - 2/8/2022

  • Package updates.

v1.2.6 - 11/23/2021

  • Package updates.

v1.2.5 - 8/30/2021

  • Package updates.

v1.2.4 - 2/17/2021

  • Add typings.
  • Use awaits in example.
  • Package updates.

v1.2.3 - 12/31/2020

  • Package updates.

v1.2.2 - 9/7/2020

  • Package updates.

v1.2.1 - 11/21/2019

  • Attempt to close existing SQL connection before opening a new one, even if it may not seem necessary.

v1.2.0 - 7/10/2019

  • Improve handling of dead connections.
  • Fix concurrency issues.

v1.1.0 - 7/26/2018

  • ES7 update.
  • Fixed bug with errors thrown by mssql being uncaught rejections, ie: server timeouts, etc.

v1.0.2 - 5/7/2018

  • Use promises recently added to the mssql library for better exception handling.

v1.0.1 - 5/7/2018

  • Make the class more object-oriented so that we can have multiple instances connecting to multiple databases.

v1.0.0 - 5/7/2018

  • Initial release.

About

A simple reusable class to query a MS SQL Server database.

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.