I need to create a meta for a spray.json.JsValue (which is actually an Option[JsValue] in my model class) for inserting it in a table with a JSON field. I tried to follow the doobie doc regarding custom mapping/JSON mapping, so I have this:
implicit val jsonMeta: Meta[JsValue] =
Meta.Advanced.other[PGobject]("json").timap[Json](
a => parse(a.getValue).leftMap[Json](e => throw e).merge)(
a => {
val o = new PGobject
o.setType("json")
o.setValue(a.noSpaces)
o
}
)
I don't know how to treat this case.
Eventually, I came up with this: