# node-red-contrib-mssql-storage-plugin

> Node-RED Storage Plugin For Microsoft SQL Server

Latest version **0.1.1** (published 2020-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-red-contrib-mssql-storage-plugin
pnpm add node-red-contrib-mssql-storage-plugin
yarn add node-red-contrib-mssql-storage-plugin
bun add node-red-contrib-mssql-storage-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2020-02-13 |
| First published | 2020-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Adam Ellis |
| Maintainers | gingerhelp.aellis |
| Keywords | node-red, mssql |

## Links

- npm: https://www.npmjs.com/package/node-red-contrib-mssql-storage-plugin
- Repository: https://github.com/gingerhelp/node-red-contrib-mssql-storage-plugin
- Homepage: https://github.com/gingerhelp/node-red-contrib-mssql-storage-plugin#readme
- Issues: https://github.com/gingerhelp/node-red-contrib-mssql-storage-plugin/issues
- npm.io page: https://npm.io/package/node-red-contrib-mssql-storage-plugin

## Dependencies (2)

- [when](https://npm.io/package/when.md) 3.7.8
- [mssql](https://npm.io/package/mssql.md) ^6.0.1

## Recent versions

- 0.1.1 (latest) — 2020-02-13
- 0.1.0 — 2020-02-13

## README

Node Red Microsoft SQL Server Storage Plugin
============================================

This plugin allows you to store your flows and library entries in Microsoft SQL Server.  Thanks to adibenmati whose MongoDb storage plugin served as a template to create this one.

Getting Started
-----

For this one, you'll need a separate script to start your Node Red,
as per the guide for running a custom Node-Red inside your process:

http://nodered.org/docs/embedding.html

Firstly, require the module:

```bash
npm install --save node-red-contrib-mssql-storage-plugin
```

Then, in your settings, add:

```javascript
const storageModule = require('node-red-contrib-mssql-storage-plugin');
const sqlConfig = {
  user: 'sa',
  password: 'myPassword',
  server: 'SQL01',
  database: 'NodeRed',
  encrypt: true
};

// Node-RED settings
const settings = {
  ...
  storageModule,
  storageModuleOptions: {
    sqlConfig,
    //optional
    //set the collection name that the module would be using
    tableNames:{
      flows: 'NodeRedFlows',
      sessions: 'NodeRedSessions',
      credentials: 'NodeRedCredentials',
      settings: 'NodeRedSettings',
      library: 'NodeRedLibrary'
    }
  },
  ...
};
```

Note that for sqlConfig I recommend storing all of the values in your .env file instead of hardcoding them like above.  Then your sqlConfig could just look like this:
```
const sqlConfig = {
  user: process.env.SQL_USER,
  password: process.env.SQL_PASSWORD,
  server: process.env.SQL_SERVER,
  database: process.env.SQL_DATABASE,
  encrypt: true
};
```

Lastly, you will need to create the tables by running the CreateTables.sql file against your database.

TODO
-----
1. I do not have the library functions working completely yet - you can save library entires but I haven't figured out what I am missing to recall them.  PRs welcome!

Q&A
-----
Q. Why the heck did you break this out into separate tables when you are primarily just deleting and inserting a single row?

A. Good question :)  The reason I am doing it this way is because I am ultimately working on a structure here to allow flows to be broken up into pieces and secured by having multiple NodeRedFlows rows as a bit of a repository and use the admin API to overwrite the "working" version via a separate frontend.  More to come on that.

---
_Source: https://npm.io/package/node-red-contrib-mssql-storage-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
