View Source EctoTemp (ecto_temp v0.1.3)

EctoTemp is use'd to set up a module for managing temp tables. Once set up, macros such as EctoTemp.Macros.deftemptable/3, EctoTemp.Macros.column/3, and macros in EctoTemp.Factory may be used.

examples

Examples

defmodule MyTest do
  use MyProject.DataCase
  use EctoTemp, repo: MyProject.Repo

  require EctoTemp.Factory
  alias EctoTemp.Factory

  deftemptable :things do
    column :data, :string, null: false
    column :data_with_default, :string, default: "default value"
    deftimestamps()
  end

  deftemptable :other_things, primary_key: false do
    column :id, :uuid, null: false
    column :data, :string, null: false
    column :data_with_default, :string, default: "default value"
    deftimestamps()
  end

  setup do
    create_temp_tables()
    :ok
  end

  test "insert records" do
    Factory.insert(:things, data: "stuff")
  end
end

Link to this section Summary

Functions

Imports EctoTemp into a module.

Link to this section Functions

Link to this macro

__using__(opts)

View Source (macro)

Imports EctoTemp into a module.

options

Options

  • :repo - required - the module defining your Ecto.Repo callbacks.

example

Example

defmodule MyModule do
  use EctoTemp, repo: MyProject.Repo
end