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

sails-sql

v0.1.0-6

Published

Flexible SQL adapter for Sails/Waterline. Supports MySQL, PostgreSQL, SQL Server (MSSQL), Oracle, & SQLite.

Downloads

54

Readme

Sails SQL Adapter

THIS IS A WORK IN PROGRESS UNDER ACTIVE DEVELOPMENT - DO NOT USE IN PRODUCTION (targeting 2019 for the first stable release w/ 3 out of 5 dialects)

SQL adapter for Node.js/Sails and Waterline. Supports MySQL, ~~PostgreSQL~~ (PostgreSQL is under construction), and Microsoft SQL Server (MSSQL) databases.

This adapter is compatible with Node ≥8 and up. For SQL adapters compatible with older versions of Node.js, see legacy adapters sails-mysql and sails-postgresql.

Running the tests

Run the tests with the SAILS_SQL_TEST_1 environment variable set to the database connection URL of an empty/throwaway database you'd like to use for testing.

If you have more than one empty/throwaway database you'd like to test against, you can include multiple URLs to run the tests back to back:

For example:

SAILS_SQL_TEST_1='mssql://root:[email protected]:8181/somethrowawaydb' SAILS_SQL_TEST_2='mysql://root:[email protected]:3306/anotherthrowaway' npm test

Acknowledgements

Thanks to dougwilson and felixge for all of their great work on mysql, @brianc for all of his fantastic work on the pg package, and thousands of contributors across the Node.js community that have made this level of simplicity and abstraction possible.

Help

For more examples, or if you get stuck or have questions, click here.

Bugs   NPM version

To report a bug, click here.

Contributing   Build Status

Please observe the guidelines and conventions laid out in the Sails project contribution guide when opening issues or submitting pull requests.

NPM

Other SQL databases

The eventual goal for this adapter is to support all of knex's supported databases, including SQLite and Oracle. (If you are using one of those databases for a real-world project, please contribute!)

License

MIT © 2018-present Mike McNeil

This package, like the Sails framework, is free and open-source under the MIT License.

Implementor notes (advanced)

About MySQL

Support for different types of managers is database-specific, and is not built into the Waterline driver spec-- however this type of configurability can be instrumented using meta.

In particular, support for ad-hoc connections (i.e. no pool) and clusters/multiple pools (see "PoolCluster": https://github.com/felixge/node-mysql/blob/v2.10.2/Readme.md#poolcluster) could be implemented here, using properties on meta to determine whether or not to have this manager produce connections ad-hoc, from a pool, or from a cluster of pools.

Feel free to fork this driver and customize as you see fit. Also note that contributions to the core driver in this area are welcome and greatly appreciated!

Also note that if this driver is adapted to support managers which spawn ad-hoc connections or manage multiple pools/replicas using PoolCluster, then relevant settings would need to be included in the manager instance so that the manager could be appropriately destroyed here (in the case of ad-hoc connections, leased connections would need to be tracked on the manager, and then rounded up and disconnected here.)

For now, since we only support a single pool, we simply destroy it.

For more info, see https://github.com/felixge/node-mysql/blob/v2.10.2/Readme.md#closing-all-the-connections-in-a-pool

About getConnection()

Note that if this driver is adapted to support managers which spawn ad-hoc connections or manage multiple pools/replicas using PoolCluster, then relevant settings would need to be included in the manager instance so that connections can be appropriately fetched/opened here. For now, since we only support a single pool, we simply acquire a connection from the pool.

About releaseConnection()

Note that if this driver is adapted to support managers which spawn ad-hoc connections or manage multiple pools/replicas using PoolCluster, then relevant settings would need to be included in the manager instance so that connections can be appropriately released/destroyed in releaseConnection.

For now, since we only support a single pool, we simply release the connection back to the pool. And if the connection cannot be released back to the pool gracefully, we try to force it to disconnect.

If releaseConnection() succeeds, then we were either able to release the connection gracefully (i.e. worked on the first try), or that we had to try again, forcibly destroying the connection.