Added Ecto, Cassandra and Auctions repo

This commit is contained in:
2026-07-15 22:21:33 +03:00
parent 94d601a458
commit 06e86abf33
11 changed files with 83 additions and 49 deletions
+18
View File
@@ -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