Commanded uses JSON as the event data and metadata serialization format by default. This means that type information is lost when serializing Elixir structs to JSON and requires one to implement the Commanded.Serialization.JsonDecoder to decode strings to their actual Elixir type, such as DateTime.
One possible option for automatic deserialization would be to provide a typespec for the domain event structs and use the defined types to deserialize events. The Spec library provides structure decoding from a typespec and could be used via a custom event store serializer.
How to deserialize events to their Elixir types.
Commanded uses JSON as the event data and metadata serialization format by default. This means that type information is lost when serializing Elixir structs to JSON and requires one to implement the
Commanded.Serialization.JsonDecoder
to decode strings to their actual Elixir type, such asDateTime
.One possible option for automatic deserialization would be to provide a typespec for the domain event structs and use the defined types to deserialize events. The Spec library provides structure decoding from a typespec and could be used via a custom event store serializer.