add shops context, clothes and users-clothes
users-clothes is a many-to-many unique relationship
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
defmodule PokemonCouture.Shops.Clothes do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
schema "clothes" do
|
||||
field :game, :string
|
||||
field :location, :string
|
||||
field :name, :string
|
||||
many_to_many :users, PokemonCouture.Accounts.User, join_through: "ownerships", unique: :true
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(clothes, attrs) do
|
||||
clothes
|
||||
|> cast(attrs, [:name, :location, :game])
|
||||
|> validate_required([:name, :location, :game])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user