peburrows / diplomat

Elixir library for interacting with Google's Cloud Datastore
94 stars 22 forks source link

The return value of Diplomat.Entity.insert/1 #35

Open s417-lama opened 6 years ago

s417-lama commented 6 years ago

According to Hex, Diplomat.Entity.insert/1's spec is:

insert([t()] | t()) :: {:ok, Diplomat.Key.t()} | Diplomat.Client.error()

However, it seems that it returns [Diplomat.Key.t()] when success. I think it should return {:ok, Diplomat.Key.t()}.

leozilla commented 5 years ago

I think it makes more sense to return a list. Because in the case the elment(s) is/are found they are present in the list and otherwise the list is empty. I would vote for fixing the type spec to insert([t()] | t()) :: [Diplomat.Key.t()] | Diplomat.Client.error()