conductor

CI task system
git clone git://git.finwo.net/app/conductor
Log | Files | Refs | README | LICENSE

dialect.js (696B)


      1 // src/lib/db/dialect.js - dialect naming and detection
      2 //
      3 // Kept separate from index.js so that configuration loading can resolve a
      4 // dialect without pulling in any driver module.
      5 
      6 export const DIALECTS = ['sqlite', 'mysql', 'postgres'];
      7 
      8 // Maps a database.url scheme onto a dialect name. An unset url means sqlite.
      9 // Returns null for a scheme that is not supported.
     10 export function dialectFromUrl(url) {
     11   if (!url) return 'sqlite';
     12   const scheme = String(url).split(':')[0].toLowerCase();
     13   if (scheme === 'mysql') return 'mysql';
     14   if (scheme === 'postgres' || scheme === 'postgresql') return 'postgres';
     15   if (scheme === 'sqlite' || scheme === 'file') return 'sqlite';
     16   return null;
     17 }