defmodule Example.App.Brand do
use Example.Schema
import Ecto.Changeset
schema "brands" do
field :brand_color, :string
field :brand_logo, :string
timestamps()
end
def changeset(brand, attrs) do
brand
|> cast(attrs, [:brand_color, :brand_logo])
|> validate_required([:brand_color, :brand_logo])
end
end
I want this schema to be a singleton, so I need to override a value which is already saved with a new value, my update function is standard and I’m doing my update trough the changeset
def update_brand(user, attrs) do
%Brand{}
|> Brand.changeset(attrs)
|> Repo.insert
end
so how can I ensure that I’m overriding the current data and not just creating a new one?