Oban.insert_all
You're seeing just the function
insert_all
, go back to Oban module for more information.
Link to this function
insert_all(name \\ __MODULE__, changesets_or_wrapper)
View Source (since 0.9.0)Specs
insert_all(name(), changesets_or_wrapper()) :: [Oban.Job.t()]
Insert multiple jobs into the database for execution.
Insertion respects prefix
and log
settings, but it does not use per-job unique
configuration. You must use insert/2,4
or insert!/2
for per-job unique support.
There are a few important differences between this function and Ecto.Repo.insert_all/3
:
- This function always returns a list rather than a tuple of
{count, records}
- This function requires a list of changesets rather than a list of maps or keyword lists
Example
1..100
|> Enum.map(&MyApp.Worker.new(%{id: &1}))
|> Oban.insert_all()
Link to this function
insert_all(name \\ __MODULE__, multi, multi_name, changesets_or_wrapper)
View Source (since 0.9.0)Specs
insert_all( name(), multi :: Ecto.Multi.t(), multi_name :: Ecto.Multi.name(), changesets_or_wrapper() | Oban.Job.changeset_list_fun() ) :: Ecto.Multi.t()
Put an insert_all
operation into an Ecto.Multi
.
This function supports the same features and has the same caveats as insert_all/2
.
Example
changesets = Enum.map(0..100, &MyApp.Worker.new(%{id: &1}))
Ecto.Multi.new()
|> Oban.insert_all(:jobs, changesets)
|> MyApp.Repo.transaction()