mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 09:56:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			554 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			554 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 'use strict';
 | |
| 
 | |
| const getDialectClass = (client) => {
 | |
|   switch (client) {
 | |
|     case 'postgres':
 | |
|       return require('./postgresql');
 | |
|     case 'mysql':
 | |
|       return require('./mysql');
 | |
|     case 'sqlite':
 | |
|       return require('./sqlite');
 | |
|     default:
 | |
|       throw new Error(`Unknown dialect ${client}`);
 | |
|   }
 | |
| };
 | |
| 
 | |
| const getDialect = (db) => {
 | |
|   const { client } = db.config.connection;
 | |
| 
 | |
|   const constructor = getDialectClass(client);
 | |
|   const dialect = new constructor(db);
 | |
|   dialect.client = client;
 | |
| 
 | |
|   return dialect;
 | |
| };
 | |
| 
 | |
| module.exports = {
 | |
|   getDialect,
 | |
| };
 | 
