src/util.js
/**
 * reads a query file and loads it into memory
 *
 * @param {string} query name of the query file
 */
reads a query file and loads it into memory
@param {string} query name of the query file
reads a query file and loads it into memory @param { string } query name of the query file
async function loadQuery(query) {
  const pathName = path.resolve(__dirname, 'queries', `${query.replace(/^\//, '')}.sql`);
  return new Promise(((resolve, reject) => {
    fs.readFile(pathName, (err, data) => {
      if (err) {
        reject(new MissingQueryError(`Failed to load .sql file ${pathName}`));
      } else {
        resolve(data.toString('utf8'));
      }
    });
  }));
}
async function loadQuery ( query ) { const pathName = path . resolve ( __dirname , 'queries' , ` ${ query . replace ( / ^\/ / , '' ) } ` ) ; return new Promise ( ( ( resolve , reject ) => { fs . readFile ( pathName , ( err , data ) => { if ( err ) { reject ( new MissingQueryError ( ` ${ pathName } ` ) ) ; } else { resolve ( data . toString ( 'utf8' ) ) ; } } ) ; } ) ) ; }
reads a query file and loads it into memory
 @param {string} query name of the query file
reads a query file and loads it into memory @param { string } query name of the query file