# crcis-mssql-context

> This package use for central connect to mssql database

Latest version **1.0.17** (published 2022-01-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install crcis-mssql-context
pnpm add crcis-mssql-context
yarn add crcis-mssql-context
bun add crcis-mssql-context
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.17 |
| Published | 2022-01-13 |
| First published | 2020-06-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Hosein Mansouri |
| Maintainers | crcis |
| Keywords | crcis, mssql |

## Links

- npm: https://www.npmjs.com/package/crcis-mssql-context
- Repository: https://gitlab.inoor.ir/infrastructure/crcis-mssql-context
- npm.io page: https://npm.io/package/crcis-mssql-context

## Dependencies (2)

- [mssql](https://npm.io/package/mssql.md) ^7.2.1
- [config](https://npm.io/package/config.md) ^3.3.6

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.17 (latest) — 2022-01-13
- 1.0.16 — 2021-11-09
- 1.0.15 — 2021-11-09
- 1.0.14 — 2021-01-02
- 1.0.13 — 2020-10-11
- 1.0.12 — 2020-10-11
- 1.0.11 — 2020-10-11
- 1.0.10 — 2020-10-11
- 1.0.9 — 2020-10-11
- 1.0.8 — 2020-09-14
- 1.0.7 — 2020-07-13
- 1.0.6 — 2020-07-01
- 1.0.5 — 2020-06-16
- 1.0.4 — 2020-06-16
- 1.0.3 — 2020-06-16
- … 3 more at https://npm.io/package/crcis-mssql-context/versions

## README

## About Project

Provide the main entry for connecting to MSSQL is the most project goal. This project is a wrapper for the MSSQL Node.js package. I use the config package for supporting multiple databases in the project.

### Config sample

```javascript
{
    "dbConfig": {
        "databaseName1": {
            "host": "DomainNameOrDomainIP",
            "port": 1433,
            "database": "YourDatabaeName",
            "userName": "YourDatabaseUserName",
            "password": "YourDatabasePassword"
        },
        "databaseName2": {
            "host": "DomainNameOrDomainIP",
            "port": 1433,
            "database": "YourDatabaeName",
            "userName": "YourDatabaseUserName",
            "password": "YourDatabasePassword"
        }
    },
}
```

### Simple Code Sample

```javascript
const context = require("crcis-mssql-context");

module.exports = async function () {
  await context
    .runCommand("databaseName", "SELECT @@VERSION AS [version]")
    .then((result) => {
      if (result !== null && result[0] !== null) console.log(result[0].version);
    })
    .catch((err) => console.log(err));
};

```
### Using Table Valued Parameters (TVP)

```javascript
const context = require("crcis-mssql-context");

module.exports.create = async (rows) => {
    let paramList = [];
    context.addInputParamToTVP("column1", "int", paramList);
    context.addInputParamToTVP("column2", "varchar", paramList);
    context.addInputParamToTVP("column3", "nvarchar", paramList);

    let tvp = context.createSqlTable(paramList);

    for (let i = 0; i < rows ; i++) {
      tvp.rows.add(
        parseInt(rows[i].value1),
        rows[i].value2,
        rows[i].value3       
      );
    }

    await context
      .runStoredProcedure("databaseName","spName", null, "tvpName",tvp)
      .then((data) => {
        
      })
      .catch((err) => {
        console.log(err);
      });
}
```

---
_Source: https://npm.io/package/crcis-mssql-context · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
