mgutz / mapper

Lightweight, blazing fast node.js ODM on top of mysql-libmysqlclient
MIT License
124 stars 11 forks source link

Configure through lambda #6

Closed mgutz closed 11 years ago

mgutz commented 11 years ago

From #5

I was thinking of feature like:

mapper.client.configure(function(client) {
  client.setOptionSync(mysql.FLAG_1, val1);
  client.setOptionSync(mysql.FLAG_2, val2);
  /* ... */
});

It may be useful if one wants to control mysql connection (as example, sometimes I need to set MYSQL_OPT_RECONNECT flag). And with such thing we can avoid much code if we'd implement different client features. What do you think about such configure(fn) feature?

estliberitas commented 11 years ago

Okay, I'll do this thing in 24 hrs. ;)

mgutz commented 11 years ago

Implemented as an optional config property

var config = { user: 'foo', password: 'secret' };
config.configureFn = function(client) {
  client.setOptionSync(mysql.MYSQL_OPT_RECONNECT, 1);
};

Mapper.connect(config);
estliberitas commented 11 years ago

Ok. You 24hrs are much more fast than mine xD Thanks!