1.1.0 • Published 6 months ago

sqlstoreprocedure v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 months ago

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 MoraAgustin Gonzalez
1.1.0

6 months ago

1.0.8

6 months ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago