gonmarques/slick-repo

Removing withId and withVersion boilerplate when one uses a case class to define an entity

Closed this issue · 0 comments

When we define an entity like test's car entity

case class Car(override val id: Option[Int] = None, brand: String, idPerson: Int) extends Entity[Car, Int] {
  def withId(id: Int): Car = this.copy(id = Some(id))
}

we always have to implement the withId method, and when we use case classes, this method will always have the same implementation based on case class copy. In Versioned entities we have the same "issue" as well.

So, believing that the users of the library will use case classes to define models in most of the cases, will be great if we generate this implementations, removing the boilerplate of this methods.

I'm working on a solution right now, I will share it soon.