From 9540b443d0957aafe2e9d15e77a7e72cc0d12792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ton=C4=87i=20Gali=C4=87?= Date: Tue, 4 Jun 2024 09:59:39 +0200 Subject: [PATCH] doc(update/4): mention expected items for updates --- lib/mongo.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mongo.ex b/lib/mongo.ex index 68e5bbad..fcb2ddf3 100644 --- a/lib/mongo.ex +++ b/lib/mongo.ex @@ -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