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.
sails-mssqlserver
✓ // Install: npm install sails-mssqlserver
// Configure in config/datastores.js:
module.exports = {
default: 'sqlserver',
datastores: {
sqlserver: {
adapter: 'sails-mssqlserver',
host: 'localhost',
port: 1433,
database: 'mydb',
user: 'sa',
password: 'password'
}
}
};
✗ const mssql = require('sails-mssqlserver');
Not a direct import; you configure the adapter in Sails datastores config. The adapter is loaded by Waterline.
sails-mssqlserver
✓ // In Sails app, no import needed; Sails loads adapters automatically from config.
✗ import sailsMssql from 'sails-mssqlserver';
The adapter is not imported directly in user code.
sails-mssqlserver
✓ // Using waterline standalone:
const Waterline = require('waterline');
const sailsMssqlAdapter = require('sails-mssqlserver');
const waterlineConfig = {
adapters: {
'sails-mssqlserver': sailsMssqlAdapter
},
datastores: {
default: {
adapter: 'sails-mssqlserver',
host: 'localhost',
port: 1433,
database: 'mydb',
user: 'sa',
password: 'password'
}
}
};
✗ const mssql = require('sails-mssqlserver');
When using Waterline standalone, you need to pass the adapter to Waterline as shown.
Shows installation, datastore config for SQL Server, model definition, and basic CRUD.
// 1. Install adapter
// npm install sails-mssqlserver
// 2. Configure datastore in config/datastores.js
module.exports.datastores = {
default: {
adapter: 'sails-mssqlserver',
host: 'localhost',
port: 1433,
database: 'mydb',
user: 'sa',
password: 'your_password_here',
options: {
encrypt: false, // set true for Azure
trustServerCertificate: true // for self-signed certs
}
}
};
// 3. Use in model (api/models/User.js)
module.exports = {
datastore: 'default',
attributes: {
name: { type: 'string', required: true },
email: { type: 'string', unique: true }
}
};
// 4. Query in controller/api
await User.create({ name: 'John', email: 'john@example.com' });
const users = await User.find();
console.log(users);
Errors
Common errors & fixes
Error: self-signed certificate in certificate chain
SQL Server uses self-signed cert; Node rejects it.
fixSet options.trustServerCertificate: true in datastore config.
ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED
SQL Server not running or wrong port/host.
fixVerify SQL Server is running and accessible on host:port. Check firewall.
error: Error: Login failed for user 'sa'.
Invalid credentials or SQL Server authentication not enabled.
fixEnsure SQL Server authentication mode allows SQL logins. Check username/password.
TypeError: Cannot read property 'type' of undefined
Missing or incorrect model attribute definition.
fixDefine attributes in model with proper types: 'string', 'number', 'boolean', etc.
Audit
Dependencies
sailsrequiredpeer dependency for adapter use
waterlinerequiredcore ORM adapter interface