martintajur/node-mysql-activerecord — pull request #13 by kylefarris (2013-08-28 18:16:55+00:00)
Title: Normalized Connection Settings

First off, great plugin. Thanks for sharing!

The connection settings were different between `node-mysql-activerecord` and `node-mysql`. This was not only confusing but also limiting. If there were certain connection flags one needed to use that are available in `node-mysql` but not in your activerecord extension ( __timezone__, __socketPath__, __insecureAuth__, etc...), they wouldn't be able to use activerecord—which would be a major bummer.

Since the only settings you were using (at the moment) dealt with connection settings for the node-mysql module, I just removed the custom object you made to pass to it and simply passed the entire settings object. This will allow users to use any of the options available to them by `node-mysql`.

Furthermore, I made it so that the changes would be backwards compatible with earlier versions. In other words, using 'server' and 'username' settings will still work. Probably would be good to deprecate when you go to _0.9.x_ and remove entirely at _1.0.0_.

If you want to support custom settings for the activerecord module itself, it could be done pretty easily in various ways.

For example:

var db = new Db.Adapter({
connection: {
server: 'localhost',
username: 'my_user',
password: 'my_password',
database: 'my_database'
},
custom: 'settings',
can: 'go here',
easy: true
});

Then it would be as easy as changing index.js to:

var connection = new mysql.createConnection(settings.connection);

I really hope you can incorporate this change.