import { DataSource } from 'typeorm';
import { AttachmentEntity } from '../../../entities';
import { rowToAttachment } from '../../mappers';

export async function handleGetAllAttachments(dataSource: DataSource) {
  const repo = dataSource.getRepository(AttachmentEntity);
  const rows = await repo.find();

  return rows.map(rowToAttachment);
}
