I've found myself needing to do a GetMulti
operation with an array of keys for which some entities exist, but some do not.
My current code, below, returns an error (datastore: no such entity
).
err := datastore.GetMulti(c, keys, infos)
So how can I do this? I'd use a "get or insert" method, but there isn't one.
GetMulti can return a
appengine.MultiError
in this case. Loop through that and look fordatastore.ErrNoSuchEntity
. For example:I know this topic is up for more than a few days, but I like to post an alternative, using type switch.