Yes, we're definitely mixing up styles. I did think it should be either just a singleton or (as how I do singletons in node) just a set of functions which are added to module.exports. However, I didn't feel I wanted to change it yet just in case I messed up the rest of the code and the memory store. Glad you brought it up though.

Ah, ok, I see what you mean about the module injections. I did wonder why there was a fair bit of indirection doing that all over.

Ok so, just to make sure I see what you're thinking:

(1) inside `db/mysql.js` we export just one function
(2) that function gets passed all the things like config, log, error, AuthToken, etc
(3) that function returns a MySql constructor function (and essentially the rest of the code just instantiates one of these)
(4) each function (such as `.createAccount()` gets a DB connection from the `this.pool`.

Am not sure where `.connect()` comes into this now. Can you clarify a bit there?

@dannycoates Other than this discussion, are you happy with how each API operation looks? It's all promised up and each gets the connection, starts a transaction (where required), does it's stuff, commits, releases the connection and then resolves with the final answer.

(Note1: also, I meant to put that `connectionLimit` into the actual config file.)

(Note2: at some point I will also need to rebase on your new binary columns.)