Atom Tweaks v0.1.0+c1f5afa AtomTweaks.Ecto.Markdown View Source

An Ecto.Type that handles the conversion between a Markdown-formatted string in the database and a AtomTweaks.Markdown struct in memory.

Use this as the type of the database field in the schema:

defmodule AtomTweaks.Tweaks.Tweak do
  use Ecto.Schema

  schema "tweaks" do
    field :title, :string
    field :code, :string
    field :type, :string
    field :description, AtomTweaks.Ecto.Markdown
    belongs_to :user, AtomTweaks.Accounts.User, foreign_key: :created_by, type: :binary_id

    timestamps()
  end
end

All other references in the codebase should be to the AtomTweaks.Markdown module. See that module's documentation on how it is used.

See: Beyond Functions in Elixir: Refactoring for Maintainability for details on this pattern.

Link to this section Summary

Functions

Casts the given input to the custom type.

Dumps the given term into an Ecto native type.

Loads the given term into a custom type.

Returns the underlying schema type for the custom type.

Link to this section Functions

Casts the given input to the custom type.

See: Ecto.Type.cast/1

Dumps the given term into an Ecto native type.

See: Ecto.Type.dump/1

Loads the given term into a custom type.

See: Ecto.Type.load/1

Returns the underlying schema type for the custom type.

See: Ecto.Type.type/0