meadow-connection-mysql

1.0.4 • Public • Published

Meadow MySQL Connection Pool Service

Simple fable service allowing access to the mysql2 connection pool in a consistent manner. For use with meadow.

let _Fable = new libFable({
		"Product": "SomeCoolApp",

		"MySQL":
			{
				"Server": "127.0.0.1",
				"Port": 3306,
				"User": "USER",
				"Password": "PASSWORD",
				"Database": "DATABASE",
				"ConnectionPoolLimit": 20
			},

        MeadowConnectionMySQLAutoConnect: true
	});
_Fable.serviceManager.addAndInstantiateServiceType('MeadowMySQLProvider', require('meadow-connection-mysql));

Then you can access the pool. If you don't set the MeadowConnectionMySQLAutoconnect flag, an extra call will need to be run to _Fable.MeadowMySQLProvider.connect() when you want to connect.

This documentation does not yet get into how to instantiate multiple connections and manage them with fable, although it can be done easily.

Using a Connection Pool

_Fable.MeadowMySQLProvider.pool.query(`SELECT * FROM Book LIMIT 10`,
	(pError, pRows, pFields) =>
	{
		// pRows is flush with books now.
		console.log(`We found ${pRows.length} books.`);
	});
}

Readme

Keywords

Package Sidebar

Install

npm i meadow-connection-mysql

Weekly Downloads

9

Version

1.0.4

License

MIT

Unpacked Size

28.7 MB

Total Files

3771

Last publish

Collaborators

  • stevenvelozo