# `Trogon.Commanded.EventStore.JsonbSerializer`
[🔗](https://github.com/straw-hat-team/beam-monorepo/blob/trogon_commanded@v1.0.1/apps/trogon_commanded/lib/trogon/commanded/event_store/jsonb_serializer.ex#L1)

A JSONB serializer based on events defined by `Trogon.Commanded.Event`.

It uses `Trogon.Commanded.Event` to cast the event to the correct type, by proxying, using `Ecto.Schema`s and
`Ecto.Changeset`s.

## Configuring

To use this serializer, add it to your `config.exs`:

    config :my_app, MyApp.EventStore,
      serializer: Trogon.Commanded.EventStore.JsonbSerializer,
      types: EventStore.PostgresTypes

# `deserialize`

Deserialize given JSON binary data to the expected type.

It is already a map since `EventStore.PostgresTypes` will take care of the deserialization. Then, it will use
`Trogon.Commanded.Event` to cast the event to the correct type.

# `serialize`

Serialize given term to JSON binary data.

It is just a passthrough, since `EventStore.PostgresTypes` will take care of the serialization.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
