View Source BitcrowdEcto.Schema (bitcrowd_ecto v0.13.1)

An opinionated set of defaults for Ecto schemas.

  • Uses Ecto.Schema and imports Ecto.Changeset and BitcrowdEcto.Changeset
  • Configures an autogenerated PK of type binary_id
  • Configures FKs to be of type binary_id
  • Sets timestamp type to utc_datetime_usec
  • Defines a type t as a struct of the schema module.
  • Defines an id type

usage

Usage

defmodule MyApp.MySchema do
  use BitcrowdEcto.Schema
end

Or if you table lives in a different Postgres schema:

defmodule MyApp.MySchema do
  use BitcrowdEcto.Schema, prefix: "foo"
end

Link to this section Summary

Functions

Safely converts a string into an enum member atom. Raises if conversion is not possible.

Safely converts a string into an enum member atom. Returns nil if conversion is not posssible.

Link to this section Functions

Link to this function

to_enum_member!(schema, field, value)

View Source (since 0.9.0)
@spec to_enum_member!(schema :: module(), field :: atom(), value :: any()) ::
  term() | no_return()

Safely converts a string into an enum member atom. Raises if conversion is not possible.

Link to this function

to_enum_member(schema, field, value)

View Source (since 0.9.0)
@spec to_enum_member(schema :: module(), field :: atom(), value :: any()) ::
  term() | nil

Safely converts a string into an enum member atom. Returns nil if conversion is not posssible.

example

Example

iex> to_enum_member(TestEnumSchema, :some_enum, "foo")
:foo