# Isn

[![Build Status](](      

Isn adds a [`Postgrex.Extension`][1] and [`Ecto.Type`][2] definitions
for the datatypes defined in the [`isn`][3] PostgreSQL module.

## Usage

1. Add the package to your Mixfile:

defp deps do
  [{:isn, "~> 0.1"}]

2. Add the isn extension to your database

{:ok, pid} = Postgrex.Connection.start_link(
  hostname: "localhost",
  database: "isn_test"
Postgrex.Connection.query!(pid, "CREATE EXTENSION isn;", [])

2. Register the postgrex extension

  database: "isn_test",
  extensions: [{Isn, {}}])

3. Start using all of the `isn` goodness in your project.

## Examples

Here are a few small snippets for how to use these types in various
contexts. I have extracted these snippets from a phoenix project, so
if you want to use them in something else, you might have to modify them
a bit.

### Ecto migrations

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

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

### Ecto Models

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

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

## 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`