Created
October 25, 2019 14:56
-
-
Save siddhant3030/1f833bf18a36ca6394b843aaa6cb5c53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Banking.Schema.Bank do | |
use Ecto.Schema | |
import Ecto.Changeset | |
alias Banking.Schema.Branch | |
schema "banks" do | |
field :name, :string | |
has_many :branches, Branch | |
timestamps() | |
end | |
def changeset(bank, attrs) do | |
bank | |
|> cast(attrs, [:name]) | |
|> validate_required([:name]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment