JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q50113F
  • License ISC

A utility library that allows you to easily interact with MAG's SQL Server in Node.js

Package Exports

  • mag-node-sql
  • mag-node-sql/NodeSQL.js

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 (mag-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

mag-node-sql

A utility library that allows you to easily interact with MAG's SQL Server in Node.js. It is a wrapper around mssql.

Getting Started

Install via npm:

npm i --save mag-node-sql

Require the library in your code:

const MagSQL = require('./NodeSQL');

Create an instance of the "MagSQL" class. Options parameter is optional (Defaults shown below):

const options = {
  database: 'GISSANDBOX',
  server: 'SQL'
};
const sql = new MagSQL(options);

Use one of the methods on your new instance. (See available functions below)

Available Methods

  • RunQuery
    • Runs a string as a sql query and returns the results as a promise
      • Example:
  • ArrayToSQLTable
    • Adds a SQL Table and adds all rows from the js array that is passed in *(Warning) This function will drop the table if the name passed in already exists!
      • Example:
        let testData = [
          {
            firstName: 'tim',
            lastName: 'johnson',
            age: 34
          },
          {
            firstName: 'marcia',
            lastName: 'brown',
            age: 28
          }
        ];
        
        sql
          .ArrayToSQLTable(testData, 'test')
          .then(result => {
            console.log(result);
          })
          .catch(err => {
            console.log(err);
          });
  • DropTable
    • Drops a sql table by name if it exists
      • Example:
        sql.DropTable('test').then(res => console.log('table dropped'));

Dependencies

  • msnodesqlv8 - ms sql server driver to allow integrated connection
  • mssql - interface with ms sql server

Authors

  • Jack Fairfield

License

This project is licensed under the MIT License.