Skip to content

Commit

Permalink
doc(update/4): mention expected items for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tonći Galić committed Jun 4, 2024
1 parent 3846ddb commit 9540b44
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/mongo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1191,12 +1191,15 @@ defmodule Mongo do
end
end

defp normalise_updates([[{_, _} | _] | _] = updates) do
# maps list of updates (which are Keyword lists) to Mongo updates
defp normalise_updates([[{_key, _value} | _rest] | _updates] = updates) do
Enum.map(updates, &normalise_update/1)
end

defp normalise_updates([{_, _} | _] = updates), do: normalise_updates([updates])
# maps a single update (= Keyword list) to Mongo update
defp normalise_updates([{_key, _value} | _rest] = updates), do: normalise_updates([updates])

# let Mongo evaluate if this is correct input
defp normalise_updates(updates), do: updates

defp normalise_update(update) do
Expand Down

0 comments on commit 9540b44

Please sign in to comment.