EctoSparkles.JSONSerdeData (ecto_sparkles v0.2.1) View Source

A custom Ecto type for handling the serialization of arbitrary data types stored as JSON data in the database. Requires the underlying DB field to be :map (eg. JSONB field).

Link to this section Summary

Functions

Callback implementation for Ecto.Type.cast/1.

Provides custom casting rules for params. Nothing changes here. We only need to handle deserialization.

Converting the data structure to a JSON binary for storage.

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Convert the JSON binary value from the database back to the desired term.

Callback implementation for Ecto.Type.type/0.

Link to this section Functions

Callback implementation for Ecto.Type.cast/1.

Provides custom casting rules for params. Nothing changes here. We only need to handle deserialization.

Converting the data structure to a JSON binary for storage.

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Convert the JSON binary value from the database back to the desired term.

Callback implementation for Ecto.Type.type/0.