Registry / database / loopback-cnn-mssql

loopback-cnn-mssql

JSON →
library1.0.5jsnpmunverified

A modern, maintained fork of the Microsoft SQL Server connector for the LoopBack framework. This package provides a datasource connector that bridges LoopBack models to MSSQL databases using the `mssql` driver. It supports both object-based and URL-based configuration, ES6+ async/await, and updated dependencies (mssql v12+). Version 1.0.5 targets Node >=10 and is suitable for LoopBack 3.x applications where the original loopback-connector-mssql is outdated. Key differentiators: actively maintained, security-focused, supports modern Node.js and MSSQL features.

npm install loopback-cnn-mssql
INSTALL
IMPORT
SIG · LOOPBACK-CNN-MSSQL
L
loopback-cnn-mssql
databasejavascriptv1.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

loopback-cnn-mssql
// In datasources.json: "connector": "loopback-cnn-mssql"
"connector": "loopback-connector-mssql"
This is a fork; use the exact connector name in LoopBack's datasources.json, not the old one.
createConnectionObject
import { createConnectionObject } from 'loopback-cnn-mssql';
const createConnectionObject = require('loopback-cnn-mssql').createConnectionObject;
The module exports a createConnectionObject function for programmatic use. Use ESM import syntax for Node >=12.
createConnectionPool
import { createConnectionPool } from 'loopback-cnn-mssql';
import { createPool } from 'loopback-cnn-mssql';
Named export is createConnectionPool, not createPool.

Configure a LoopBack datasource and use the connector programmatically to query MSSQL.

// datasources.json { "sqlserverdb": { "name": "sqlserverdb", "connector": "loopback-cnn-mssql", "host": "localhost", "port": 1433, "database": "mydb", "user": "sa", "password": "YourPassword!", "trustServerCertificate": true, "options": { "encrypt": true } } } // server.js (programmatic usage) import { createConnectionObject } from 'loopback-cnn-mssql'; const config = { host: 'localhost', port: 1433, database: 'mydb', user: 'sa', password: 'YourPassword!' }; const connection = await createConnectionObject(config); const result = await connection.query('SELECT 1 AS test'); console.log(result);
Debug
Known issues
breakingThe URL configuration property 'url' overrides individual host/database properties. If both are set, the URL takes precedence, but explicit properties can override URL parts. This can lead to unexpected connections if not used carefully.
fix
Either use only URL or only explicit properties; if mixing, ensure intent is clear.
affects: >=1.0.0
gotchaNamed instances must use the format 'HOST\\INSTANCE' in the host field, not a separate property. This differs from other MSSQL connectors.
fix
Set host to 'localhost\\SQLEXPRESS' or similar.
affects: >=1.0.0
gotchaThe 'trustServerCertificate' option is false by default. If connecting to a local instance with a self-signed certificate, the connection will fail unless this is set to true.
fix
Add "trustServerCertificate": true to datasource config.
affects: >=1.0.0
breakingNode.js versions below 10 are not supported. This fork uses async/await and ES6+ features.
fix
Upgrade to Node >=10.
affects: >=1.0.0
deprecatedLoopBack 3 is end-of-life; running this connector on LoopBack 3 is possible but not recommended for production.
fix
Consider migrating to LoopBack 4 or using the connector programmatically outside LoopBack.
affects: all
Errors
Common errors & fixes
Error: Self-signed certificate in certificate chain
MSSQL server uses a self-signed certificate and trustServerCertificate is not set to true.
fix
Add "trustServerCertificate": true to the datasource configuration.
Error: Login failed for user 'sa'
Incorrect username or password, or SQL Server authentication is disabled.
fix
Verify credentials and ensure SQL Server is configured for mixed mode authentication.
Error: Cannot open database 'mydb' requested by the login. The login failed.
The specified database does not exist or the user does not have access.
fix
Create the database or grant access to the user.
Error: connect ETIMEDOUT
MSSQL server is unreachable (network issue, firewall, or wrong host/port).
fix
Check host, port, network connectivity, and firewall rules.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
mssqlrequiredUnderlying database driver for MSSQL
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
loopback-cnn-mssql — npm install loopback-cnn-mssql · libregistry