1.0.0 • Published 8 months ago

mssql-by-steve v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

mssql-by-steve

Finally, a mssql wrapper for the rest of us

Installation

npm install mssql-by-steve

Usage

Create a new ts file, initialize SqlHelper

Option 1: Initialize with configuration:

import SqlHelper from 'mssql-by-steve';

SqlHelper.initialize({
    user: "your_username",
    password: "your_password",
    server: "your_server",
    database: "your_database"
});

Option 2: initialize using environment variables:

import SqlHelper from 'mssql-by-steve';

SqlHelper.initializeFromEnv();
// Reads from: db_user, db_password, server, database

Export SqlHelper then import it from anywhere in your application and use it:

import SqlHelper from 'path-to-your-initialization-file';
const result = await SqlHelper.executeSingle<string>(
    'Text',
    `SELECT SomeColumn FROM SomeTable WHERE SomeColumn = @someValue`,
    [
        {name: 'someValue', type: 'VarChar', value: 'SomeValue'}
    ]
);
1.0.0

8 months ago