Postgrex.Extension and Ecto.Type for PostgreSQL isn module
Go to file
Martin Frost 8a40849e7c Ignore emacs *~ temp files 2016-01-10 12:46:28 +01:00
config WIP 2015-05-05 22:15:40 +02:00
lib Ignore emacs *~ temp files 2016-01-10 12:46:28 +01:00
test Rename Isn -> ISN 2016-01-10 12:12:38 +01:00
.gitignore Ignore emacs *~ temp files 2016-01-10 12:46:28 +01:00
.travis.yml Add .travis.yml file 2015-10-02 21:45:30 +02:00
README.md Update README with new installation instructions 2016-01-10 12:41:39 +01:00
mix.exs Version 1.0.0 2016-01-10 12:42:28 +01:00
mix.lock Bump dependencies, and version 2016-01-03 22:17:57 +01:00

README.md

ISN

Build Status

ISN adds a Postgrex.Extension and Ecto.Type definitions for the datatypes defined in the isn PostgreSQL module.

Usage

Ecto migrations

defmodule MyApp.Repo.Migrations.CreateBook do
  use Ecto.Migration

  def change do
    create table(:books) do
      add :isbn, :isbn13
      # other fields
    end
  end
end

Ecto Models

defmodule MyApp.Book do
  use MyApp.Web, :model

  schema "books" do
    field :isbn, ISN.ISBN13
    # other fields
  end
end

Installation

  1. Add the package to your Mixfile:

    defp deps do
      [{:isn, "~> 0.1"}]
    end
    
  2. Add the isn extension to your database

    mix do isn.gen.migration, ecto.migrate
    
  3. Register the postgrex extension in your Repo config

    config :books, MyApp.Repo,
    adapter: Ecto.Adapters.Postgres,
    extensions: [{Isn, []}]
    
    

Defined types

ISN adds the following ecto and corresponding postgrex types:

Ecto.Type Postgrex type
ISN.ISBN :isbn
ISN.ISBN13 :isbn13
ISN.ISMN :ismn
ISN.ISMN13 :ismn13
ISN.ISSN :issn
ISN.ISSN13 :issn13
ISN.EAN13 :ean13
ISN.UPC :upc