Skip to content

Instantly share code, notes, and snippets.

@bastienmichaux
Last active July 7, 2017 08:46
Show Gist options
  • Save bastienmichaux/3832193a44f00338a9f261cfae7b5d2c to your computer and use it in GitHub Desktop.
Save bastienmichaux/3832193a44f00338a9f261cfae7b5d2c to your computer and use it in GitHub Desktop.
db-importer refactoring sketch
//mysql.js
const getConnection = () => foo();
const importTables = () => bar();
const getConstraints = () => xyz();
module.exports = {getConnection, importTables, getConstraints};
//sqlite.js : idem
const getConnection = () => fizz();
const importTables = () => qux();
const getConstraints = () => arg();
module.exports = {getConnection, importTables, getConstraints};
//etc...
//index.js
const dbms = () => somethingSomething; // return the appropriate module
const connection = dbms().getConnection();
const tables = dbms().importTables();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment