1.0.23 • Published 1 year ago

mag-node-sql v1.0.23

Weekly downloads
4
License
ISC
Repository
github
Last release
1 year ago

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

Links

Authors

  • Jack Fairfield

License

This project is licensed under the MIT License.

1.0.23

1 year ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

5 years ago

1.0.8

5 years 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

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago