felixge/node-mysql — pull request #319 by dresende (2012-11-03 21:16:15+00:00)
Title: User plugins

I don't this module full with bloated code, that's why I'm making this pull request. I'm sure my opinion is shared by others. The main goal is to create a simple way of creating plugins outside this module and be able to change some behavior and add features that should not belong in the core module.

I'm creating some plugins just to see what a user might need to be able to freely extend the module (at their own risk).

The base idea is to use the connect/express syntax. You create a connection and then extend it with plugins:

```js
var mysql = require('mysql');
var fooPlugin = require('mysql-user-plugin');
var connection = mysql.createConnection('...');

connection.use(mysql.BundledPlugin);
connection.use(fooPlugin(1, 'a', ...));
```

Some ideas for plugins:

1. SQL formatting ('?' substitution - #212, #294, #316)
2. Connection state (#314)
3. Procedure calls - this is one of the test plugins I created (#287)
4. ...

Currently, `Connection.use` expects a function that will be called immediately with the `Connection` has first and only argument.

I would like some feedback about this. What do you all think?