Advertisement
Guest User

index.js

a guest
Feb 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const patchwork = require('./patchwork')
  2. sql.Promise = Promise;
  3. (async () => {
  4.     try {
  5.         console.log('Connecting to database...');
  6.         const db = new Database();
  7.         await db.init();
  8.  
  9.         for (let patch of patchwork) {
  10.             if (typeof patch === 'string') {
  11.                 await db.exec(patch);
  12.             } else if (typeof patch === 'function') {
  13.                 let script = await patch(db);
  14.                 if (typeof script === 'string' && script.length) {
  15.                     await db.exec(script);
  16.                 }
  17.             }
  18.         }
  19.  
  20.         console.log('Done!');
  21.         process.exit(0);
  22.     } catch (ex) {
  23.         console.error(ex);
  24.         process.exit(0);
  25.     }
  26. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement