Added Ecto, Cassandra and Auctions repo
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
defmodule Auction do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "auctions" do
|
||||
field :gid, :string, primary_key: true
|
||||
field :author_gid, :string
|
||||
field :starting_price, :decimal
|
||||
end
|
||||
|
||||
def changeset(auction, params \\ %{}) do
|
||||
auction
|
||||
|> cast(params, [:gid, :author_gid, :starting_price])
|
||||
|> validate_required([:gid, :author_gid, :starting_price])
|
||||
|> validate_number(:starting_price, greater_than_or_equal_to: 0)
|
||||
|> unique_constraint([:gid])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user