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 🙏

© 2024 – Pkg Stats / Ryan Hefner

any-db-mssql

v0.1.0

Published

The MSSQL adapter for any-db

Downloads

497

Readme

any-db-mssql

This is the MSSQL adapter for Any-DB. It relies on the Tedious database driver to create connection and query objects that conform to the Any-DB API.

This adapter is not yet fully compatible with Any-DB, because Query objects are not instances of stream.Readable, they are just event emitters. It means that they do not provide pause and resume methods yet.

API extensions

The connections this module creates inherit from the constructor functions in require('tedious'), so any methods that tedious supports beyond those specified by Any-DB Connection are also available to you.

Keep in mind that these methods will not necessarily work with other backends.

Module extends Any-DB API by providing support for both positional and named parameters. Positional parameters are actually emulated (they're converted to named parameters) because Tedious does not support them.

Module provides additional read-only variables:

  • namedParameterPrefix, defaults to '@'
  • positionalParameterPrefix, defaults to '?'

which can be used when building SQL queries. In most other data bases, named parameters are marked with colon prefix, but MSSQL uses at character.

Additionally parameter values can be objects, each with two properties:

  • type
  • value

Where type is a Tedious type object, which can be obtained through a call to getTypeByName('typeName') function, also provided by this module. Aside from "native" types used by Tedious and MSSQL, following "generic" types are recognized (following example set by Sails):

  • integer
  • float
  • real
  • boolean
  • text
  • string
  • date
  • time
  • datetime
  • binary

Unrecognized types will be handled as binary type.

Tedious type can be obtained through a call to detectParameterType(value) function too. Difference is that getTypeByName "translates" type name to Tedious type, while detectParameterType returns Tedious type based on the JavaScript type of value passed to it.

Install

npm install any-db-mssql

Running tests

Before running tests, set some environment variables to configure access to the data base (in Windows shell, replace export with set):

export DB_NAME=test
export DB_USER=sa
export DB_PASS=test123
export DB_INST=SQLEXPRESS
export DB_HOST=localhost

Each of the environment variables mentioned above is optional, test will use defaults if value will not be provided.

Install all dependencies needed for testing:

npm install

Run tests the node way:

npm test

See test configuration file (test/support/config.js) for more information.

To test against any-db-adapter-spec, call its test from any-db-mssql adapter's directory set as current directory, i.e., it can be called right after npm test mentioned above:

node ../node-any-db-adapter-spec/bin/test-any-db-adapter --url 'mssql://'$DB_USER':'$DB_PASS'@'$DB_HOST'/'$DB_NAME'?instanceName='$DB_INST

In Windows shell, use following command line:

node ..\node-any-db-adapter-spec\bin\test-any-db-adapter --url "mssql://%DB_USER%:%DB_PASS%@%DB_HOST%/%DB_NAME%?instanceName=%DB_INST%"

node-any-db-adapter-spec files should exist before running command mentioned above.

Documentation

Generate documentation using JSDoc:

jsdoc -c jsdoc.json -d documentation index.js

License

3-clause BSD