2
サブ文書のリストが埋め込まれた文書があります。 Ectoを使用して埋め込みリストの特定のドキュメントを更新/変更するにはどうすればよいですか?埋め込みリスト内の1つのサブ文書をEctoで更新するには?
defmodule MyApp.Thing do
use MyApp.Model
schema "things" do
embeds_many :users, User
end
end
defmodule MyApp.User do
use MyApp.Model
embedded_schema do
field :name, :string
field :email, :string
field :admin, :boolean, default: false
end
end
defmodule MyApp.Model do
defmacro __using__(_) do
quote do
use MyApp.Web, :model
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id # For associations
end
end
end