Registry / database / sails-sqlserver

sails-sqlserver

JSON →
library2.0.2jsnpmunverified

MSSQL adapter for Sails.js and Waterline ORM. Current stable version is 2.0.2, supporting Sails 1.x. Designed to allow Sails applications to connect to Microsoft SQL Server databases, including Azure SQL. It provides Waterline-compatible model operations (create, read, update, delete) and exposes a `query()` method for raw SQL. Maintenance is minimal; the adapter is largely stable but receives infrequent updates. Compared to the official `sails-sqlserver`, this package is community-maintained and may have less active support.

npm install sails-sqlserver
INSTALL
IMPORT
SIG · SAILS-SQLSERVER
S
sails-sqlserver
databasejavascriptv2.0.2
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.

sails-sqlserver
require('sails-sqlserver')
import sailsSqlserver from 'sails-sqlserver'
Sails adapters are configured via sails.config.datastores, not directly imported in application code. This require is used in the adapter config.
adapter
module.exports = require('sails-sqlserver')
module.exports = { adapter: 'sails-sqlserver' }
In a custom adapter or when using the adapter as a module, export the adapter directly. However, most usage is via datastore config.
Waterline
import Waterline from 'waterline'
const Waterline = require('waterline').Waterline
Waterline can be used standalone. Ensure you import the default export.

Configure the adapter as the default datastore, define a model, perform CRUD operations, and run raw SQL.

// In config/datastores.js module.exports.datastores = { default: { adapter: 'sails-sqlserver', url: process.env.MSSQL_URL || 'mssql://sa:your_password@localhost:1433/your_database', }, }; // In a model (e.g., api/models/User.js) module.exports = { datastore: 'default', attributes: { name: { type: 'string', required: true }, email: { type: 'string', required: true }, }, }; // Usage in a controller await User.create({ name: 'John', email: 'john@example.com' }); const users = await User.find(); // Raw SQL const result = await sails.getDatastore().sendStatement('SELECT * FROM users');
Debug
Known issues
deprecatedsails-sqlserver is a community fork and may not receive updates for newer Sails versions.
fix
Consider using the official sails-sqlserver package from Sails core (npm install sails-sqlserver --save) or migrate to another adapter.
affects: >=2.0.0
gotchaThe package name on npm is 'sails-mssql', but the repository is 'sails-sqlserver'. Ensure you install 'sails-mssql' not 'sails-sqlserver'.
fix
Run `npm install sails-mssql` and configure adapter as 'sails-mssql' in datastores config.
affects: *
gotchaConnection URL format: 'mssql://username:password@host:port/database' is used, not standard SQL Server connection strings.
fix
Use the correct URL format: mssql://user:pass@host:port/dbname
affects: *
breakingSails v1.x requires adapter version 2.x; version 1.x is for Sails 0.12.x.
fix
If using Sails 1.x, ensure you have sails-mssql@2.x installed. For Sails 0.12, use sails-mssql@1.x.
affects: >=1.0.0
gotchaThe adapter does not support transactions natively; you must use raw queries for transactional operations.
fix
Use sails.getDatastore().sendStatement() with BEGIN TRAN/COMMIT/ROLLBACK.
affects: *
Errors
Common errors & fixes
Error: No SQL Server connection could be made because the target machine actively refused it.
SQL Server not running or blocked by firewall/port issues.
fix
Start SQL Server service, ensure port 1433 is open, and verify the connection URL host/port.
Error: Login failed for user 'sa'.
Incorrect username/password or SQL Server authentication mode not set to mixed.
fix
Check credentials in connection URL and ensure SQL Server is configured for SQL Server Authentication (mixed mode).
Error: Could not find any adapters for datastore 'default'
Adapter not installed or not configured correctly in datastores.js
fix
Run `npm install sails-mssql --save` and set adapter: 'sails-mssql' in config/datastores.js
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
waterlineoptionalRuntime peer dependency; the adapter integrates with Waterline ORM
Agent activity
6 hits · last 30 days
node
4
Meta
1
Resources
sails-sqlserver — npm install sails-sqlserver · libregistry