all files / lib/ index.js

90.91% Statements 10/11
91.67% Branches 11/12
100% Functions 1/1
90.91% Lines 10/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                  15×       15×                                    
/**
 * Configuration is dodo-objection configuration.
 *
 * @param config Dodo-objection configuration.
 * @return {DatabaseManager}
 */
module.exports = {
  databaseManagerFactory: function databaseManagerFactory(config) {
 
    // Prevent people from invoking this as a constructor.
    Iif (this instanceof databaseManagerFactory) {
      throw new Error('this is not a constructor');
    }
 
    switch (config.knex.client) {
      case 'pg':
      case 'postgresql':
      case 'postgres': {
        var PostgresDatabaseManager = require('./PostgresDatabaseManager').default;
        return new PostgresDatabaseManager(config);
      }
      case 'maria':
      case 'mariadb':
      case 'mariasql':
      case 'mysql': {
        var MySqlDatabaseManager = require('./MySqlDatabaseManager').default;
        return new MySqlDatabaseManager(config);
      
      }
      case 'sqlite3':
      case 'sqlite': {
        var SqliteDatabaseManager = require('./SqliteDatabaseManager').default;
        return new SqliteDatabaseManager(config);
      }
      default:
        throw new Error(config.knex.client + ' is not supported. Supported clients currently: postgres, mysql and sqlite');
    }
  }
};