Skip to content

Instantly share code, notes, and snippets.

@Yamo93
Created November 17, 2020 06:57
Show Gist options
  • Save Yamo93/9c15e972ef04751afd0191482b59ba17 to your computer and use it in GitHub Desktop.
Save Yamo93/9c15e972ef04751afd0191482b59ba17 to your computer and use it in GitHub Desktop.
function initializeDatabase(database) {
if (typeof database.init !== 'function') {
throw 'Engine has no init method';
}
database.init();
}
const mySqlEngine = {
type: 'mysql',
init: function () {
// ...
}
};
const postgresEngine = {
type: 'postgres',
init: function () {
// ...
}
};
initializeDatabase(mySqlEngine);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment