Giter VIP home page Giter VIP logo

isn's Introduction

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, read_after_writes: true
    # other fields
  end
end

Installation

Add the package to your Mixfile

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

Add the isn extension to your database

mix do isn.gen.migration, ecto.migrate

Add a lib/postgrex_types.ex file with the following content:

Postgrex.Types.define(MyApp.PostgrexTypes, [ISN], [])

Add the following lines in config.exs:

config :my_app, MyApp.Repo,
  types: MyApp.PostgrexTypes

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

isn's People

Contributors

dependabot[bot] avatar frost avatar linusdm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

isn's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.