JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q62276F
  • License MIT

A simple node wrapper for the wonderful Tedious driver.

Package Exports

  • node-sql

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-sql) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-sql

A simple node-style callback wrapper for the wonderful Tedious driver.

Just call the exec function with a query, and get back an Array of JSON objects with column name => column value

##exec(query, config, callback) query: String - 'Select * From tbl'.

config: Object - standard tedious config object.

callback: Function - standard node callback, returns (err, result). Where err = Error, and result = the query results.

var nodeSQL = require('node-sql')
//standard tedious config object : http://tediousjs.github.io/tedious/api-connection.html#function_newConnection
var config = {
  userName: process.env.USERNAME,
  password: process.env.PASSWORD,
  server: 'MyServer',
  domain: 'DOMAIN'
}
//result has data as an Array of JSON objects with column name => column value
app.get('/', function (req, res) {
  nodeSQL.exec(`
    Select FirstName, LastName From tbl Where FirstName='Moshe'
  `, config, function(err, result){
    if(err) res.status(500).json(err);
    res.status(200).json(result);// [{FirstName: 'Moshe', LastName: 'Karmel'}]
  });
})

Installation

$ npm install node-sql --save

License

MIT