message: Add a helper for running queries in a transaction
diff: import { pickBy } from 'lodash';
  +import { Client } from 'pg';
  const camelToSnakeCase = (str: string) => str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
  @@ -36,3 +37,20 @@ export function buildConditions(params: any, tableName?: string) {
  values: Object.values(nonNullParams),
  };
  }
  +
  +export async function inTransaction(db: Client, cb: any) {
  + let isTestEnv = process.env.NODE_ENV === 'test';
  +
  + if (isTestEnv) {
  + await cb(); // Don't commit any data to the test db
  + } else {
  + try {
  + await db.query('BEGIN');
  + await cb();
  + await db.query('COMMIT');
  + } catch (e) {
  + await db.query('ROLLBACK');
  + throw e;
  + }
  + }
  +}
  