Skip to content

Add doobie-postgres-tethys integration #2247

Open
@Roman-Statsura

Description

@Roman-Statsura

How do you feel about adding a new module with Put and Get instances for json and jsonb for tethys similar to doobie-postgres-circe?

smth like that

trait JsonBTethysInstances {

  implicit private val showPGobject: Show[PGobject] = Show.show(_.getValue.take(250))

  def jsonbPut[T: JsonWriter]: Put[T] =
    Put.Advanced.other[PGobject](
      NonEmptyList.of("jsonb")
    ).tcontramap { a =>
      val o = new PGobject
      o.setType("jsonb")
      o.setValue(a.asJson)
      o
    }

  def jsonbGet[T: JsonReader]: Get[T] =
    Get.Advanced.other[PGobject](
      NonEmptyList.of("jsonb")
    ).temap(_.getValue.jsonAs[T].leftMap(_.getMessage))
}

and the similar for "json"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions