sqlstoreprocedure
v1.1.0
Published
Librery for nodejs that allows to execute store procedure for SQL Server
Downloads
18
Readme
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 | | :---: | :---: |