Trash.Schema (trash v0.1.0)

Provides functions for integrating Trash with Ecto.Schema.

Example

defmodule MyApp.Post do
  use Ecto.Schema
  use Trash.Schema

  schema "posts" do
    field(:title, :string)
    trashable_fields()
  end
end

Link to this section Summary

Functions

Imports functions from Trash.Schema.

Declares fields on Ecto.Schema necessary for Trash.

Link to this section Functions

Link to this macro

__using__(list)

(macro)

Specs

__using__(options :: list()) :: Macro.t()

Imports functions from Trash.Schema.

Currently no options are available.

Link to this macro

trashable_fields()

(macro)

Specs

trashable_fields() :: Macro.t()

Declares fields on Ecto.Schema necessary for Trash.

This is a macro that can be used inside of an Ecto.Schema.schema/2 block to add the necessary fields.

Fields

  • discarded_at - :utc_datetime
  • discarded? - :boolean (virtual)

Note: under normal circumstances, discarded? will be nil since it's not possible to load a virtual field in Ecto. Instead, use Trash.Query.select_trashable/1 to hydrate this field with a computed value from the database.