gregbrowndev / projects

1 stars 0 forks source link

Refactor repositories to collection-oriented #56

Open gregbrowndev opened 1 year ago

gregbrowndev commented 1 year ago

Repositories should follow a collection-oriented style with a save function to handle upserting the object as a unit of state.

Example:

trait JobRepository[F[_]: MonadCancelThrow] {
  def nextIdentity(): F[JobId]

  def save(job: Job): EitherT[F, String, Unit]

  def delete(job: Job): EitherT[F, String, Unit]

  def get(id: JobId): EitherT[F, String, Job]

  def find(
      filterOpt: Option[JobFilter],
      paginationOpt: Option[Pagination]
  ): F[List[Job]]
}