Riptide.Mutation.chunk

You're seeing just the function chunk, go back to Riptide.Mutation module for more information.

Takes a stream of mutations, combines them in batches of size count. Useful when writing a lot of mutations that would be faster written as batches.

Examples

iex> 1..10
...> |> Stream.map(fn index -> Riptide.Mutation.put_merge(["data", to_string(index)], index) end)
...> |> Riptide.Mutation.chunk(5)
...> |> Enum.to_list()
[
  %Riptide.Mutation{
    delete: %{},
    merge: %{"data" => %{"1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5}}
  },
  %Riptide.Mutation{
    delete: %{},
    merge: %{"data" => %{"10" => 10, "6" => 6, "7" => 7, "8" => 8, "9" => 9}}
  }
]