我有以下架构:
@primary_key false
schema "companies" do
field :number, :integer, primary_key: true
field :name, :string
field :street, :string
field :zipcode, :integer
field :location, :string
field :phone, :integer
field :company_class, :string
field :country_iso, :string
field :email, :string
field :password, :string, virtual: true
field :password_hash, :string
has_many :contacts, Busiket.Contact, on_delete: :delete_all
timestamps
end
def register(struct, params \\ %{}) do
end
如果通过寄存器功能创建变更集,如何为字段number
生成数字?
如果数字已经可用,我如何首先验证数据库,以避免重复。