improvement: add context option to bulk_create

This commit is contained in:
Zach Daniel 2023-09-27 12:09:37 -04:00
parent c571625557
commit 9f97569dce
2 changed files with 6 additions and 1 deletions

View file

@ -125,6 +125,7 @@ defmodule Ash.Actions.Create.Bulk do
})
|> Ash.Actions.Helpers.add_context(opts)
|> Ash.Changeset.set_context(%{bulk_create: %{index: index}})
|> Ash.Changeset.set_context(opts[:context] || %{})
|> Ash.Changeset.prepare_changeset_for_action(action, opts, input)
|> Ash.Changeset.run_before_transaction_hooks()
end)

View file

@ -381,7 +381,11 @@ defmodule Ash.Api do
type: :atom,
doc:
"The identity to use when detecting conflicts for `upsert?`, e.g. `upsert_identity: :full_name`. By default, the primary key is used. Has no effect if `upsert?: true` is not provided"
],
,
context: %{
type: :map,
doc: "Context to set on each changeset"
},
upsert_fields: [
type: {:list, :atom},
doc: