function inflateTransactions(db, accountId, transactions = [], sourceName) {
  const transactionJSONs = transactions.map((t) => (t.toJSON ? t.toJSON() : t))

  transactionJSONs.forEach((t) => {
    t.cursor = t.id;
    t.accountId = accountId;
  });

  const byModel = _.groupBy(transactionJSONs, "object");
  const byObjectIds = _.groupBy(transactionJSONs, "objectId");

  return Promise.all(Object.keys(byModel).map((modelName) => {
    const modelIds = byModel[modelName].filter(t => t.event !== 'delete').map(t => t.objectId);
    const modelConstructorName = modelName.charAt(0).toUpperCase() + modelName.slice(1);
    const ModelKlass = db[modelConstructorName]

    let includes = [];
    if (ModelKlass.requiredAssociationsForJSON) {
      includes = ModelKlass.requiredAssociationsForJSON(db)
    }
    return ModelKlass.findAll({
      where: {id: modelIds},
      include: includes,
    }).then((models) => {
      const remaining = _.difference(modelIds, models.map(m => `${m.id}`))
      if (remaining.length !== 0) {
        const badTrans = byModel[modelName].filter(t =>
          remaining.includes(t.objectId))
        console.error(`While inflating ${sourceName} transactions, we couldn't find models for some ${modelName} IDs`, remaining, badTrans)
      }
      for (const model of models) {
        const transactionsForModel = byObjectIds[model.id];
        for (const t of transactionsForModel) {
          t.attributes = model.toJSON();
        }
      }
    });
  })).then(() => transactionJSONs)
}
A Transaction references objects that changed. This finds and inflates
those objects.

Resolves to an array of transactions with their `attributes` set to be
the inflated model they reference.