npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spinajs/orm-mssql

v2.0.502

Published

orm mssql integration

Readme

@spinajs/orm-mssql

The Microsoft SQL Server dialect driver for @spinajs/orm, built on @spinajs/orm-sql.

Known defect: inserts fail

This driver registers no ServerResponseMapper. Every driver must — the shape of an insert response is dialect-specific and the base class has no default. Any path that reads an insert response therefore throws:

no ServerResponseMapper is registered for this connection. Every driver must register one:
container.register(MyMapper).as(ServerResponseMapper)

That covers Model.insert(), model.insert(), model.save() and every upsert. It reproduces from this package's own suite — npm test gives 10 passing, 2 failing, both with that message.

The fix is a mapper reading the SELECT SCOPE_IDENTITY() as ID that MsSqlInsertQueryCompiler already appends to every insert, registered in resolve(). See docs/README.md for a working implementation.

Until then, treat this driver as read-capable only. Selects, schema operations and transactions all work.

Install

npm install @spinajs/orm @spinajs/orm-mssql

Usage

import { DI } from '@spinajs/di';
import { Orm } from '@spinajs/orm';
import { MsSqlOrmDriver } from '@spinajs/orm-mssql';

DI.register(MsSqlOrmDriver).as('orm-driver-mssql');
await DI.resolve(Orm);
// configuration
{
  db: {
    DefaultConnection: 'mssql',
    Connections: [
      {
        Name: 'mssql',
        Driver: 'orm-driver-mssql',
        Host: '127.0.0.1',
        Port: 1433,
        User: 'sa',
        Password: 'Str0ng!Passw0rd',
        Database: 'app',
        Options: { Schema: 'dbo', encrypt: false, trustServerCertificate: true },
      },
    ],
  },
}

What is distinctive

  • AliasSeparator defaults to #, not $$ begins a pseudo-column in T-SQL.
  • Backticks are stripped from every statement before it is sent, since T-SQL quotes with [brackets].
  • Three-part table names[database].[schema].[table], via Options.Schema.
  • OFFSET ... FETCH NEXT instead of LIMIT. It is emitted only when a limit is set, so skip() without take() applies no offset — and T-SQL requires an ORDER BY before OFFSET.
  • DELETE TOP (n) for limited deletes.
  • INSERT IGNORE throwsInsertBehaviour.InsertOrIgnore is unsupported.
  • Multi-column ORDER BY is reduced to one column.
  • No native SET, ENUM or JSON, so whereInSet / whereNotInSet do not work here and @Json() is required for JSON columns.
  • DDL is transactional, unlike MySQL — Migration.Transaction.Mode = PerMigration gives a genuinely atomic migration.

Documentation

Full documentation lives in docs/.

| | Page | | --- | --- | | 01 | Configuration | | 02 | Dialect notes |

Development

npm test        # 10 passing, 2 failing — see the defect above
npm run build