sqlstoreprocedure
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Tested with mocha

https://nodei.co/npm/sqlstoreprocedure.png?downloads=true&downloadRank=true&stars=true

SQLStoreProcedure

Quick and easy MSSQL Stored Procedure execution using promises

If you don't know how to operate with promises please refer to the following links:

Install

npm install sqlstoreprocedure --save

or

yarn add sqlstoreprocedure

Usage

Parameters

The library allows for native JS object primitives

const parameters = {
    Param1 : "value",
    Param2 : 2,
    Param3 : true
};

Execution

In order to start oeprating we must first initialize the module:

const SQLSP = require('sqlstoreprocedure')
const sp = new SQLSP('userdb', 'IPServer(x.x.x.x)', 'databasename', 'password');

sp.exec('StoredProcedureName', parameters).then((response) => {
    // Handle response
    console.log(response);
}).catch((error) => {
    console.log(`SP Error: ${error}`);
})

Example with await

const SQLSP = require('sqlstoreprocedure')

// Normal version
async function main (){
  const sp = new SQLSP('userdb', 'IPServer(x.x.x.x)', 'mydatabase', 'mysecurepassword');
  const response = await sp.exec('StoredProcedure', parameters);

  // Handle response
  console.log(response);
}

// Arrow Function Version
let main = async () => {
  const sp = new SQLSP('userdb', 'IPServer(x.x.x.x)', 'mydatabase', 'mysecurepassword');
  const response = await sp.exec('StoredProcedure', parameters);

  // Handle response
  console.log(response);
}

main();

Example with typescript

import SQLSP from 'sqlstoreprocedure';

let sp: any = new SQLSP('userdb', 'IPServer(x.x.x.x)', 'mydatabase', 'mysecurepassword')

sp.exec('StoredProcedure', parameters).then(response => {
    // Handle response
  console.log(response);
}).catch(err => {
    console.log(err)
})

Contributors


Juan Mora

Agustin Gonzalez

Package Sidebar

Install

npm i sqlstoreprocedure

Weekly Downloads

11

Version

1.1.0

License

MIT

Unpacked Size

8.42 kB

Total Files

5

Last publish

Collaborators

  • agustingonzalezmurua
  • raicerk