This is almost good. With minor changes, as shown below, it should work:
// I added below T: ColumnType
def updateInvoiceField[T: ColumnType](id: Int, fieldExtractor: (Invoices) => Rep[T], newValue: T): Future[Int] = {
db.run {
val adminStatus = InvoicesTable.filter(invoice => invoice.id === id).map(invoice => {
fieldExtractor(invoice)
})
adminStatus.update(newValue)
}
}
Notice, I added this one : ColumnType, which basically means that you should have a proper implicit scope - in particular, one that will convert T=> ColumnType[T]. This is simply because it Tcan be anything else, but Slicknot be able to understand how to transform it.
, , String, Int .., , , ( api /). MappedColumnType . ( ):
implicit def columnType[T]: BaseColumnType[Id[T]] =
MappedColumnType.base[Id[T], Long](toLong, fromLong)
private def fromLong[T](dbId: Long): Id[T] = Id(dbId)
private def toLong[T](id: Id[T]): Long = id.value