Repository navigation
datastore.get should handle entity not found better #10
Description
Activity
I was thinking that current case (null #error, undefined #key, undefined #entity) would be explicit enough to say entity is not found. Returning a dedicated error would be another option but it gets annoying to handle errors on methods that work with multiple entities (getAll, saveAll, deleteAll).
maybe
cb(null, null, null)would be more appropriate thatcb(null, undefined, undefined).I'm not sure what nodejs developer expect for empty result, what seems weird in my case is that I can
undefinedas the result even if my lookup RPC is valid.I will pass null, null, null for consistency. Developer's way of interacting with this library is likely to be changed -- depending on which subset of JavaScript they like for sure.
if(!entity) { // not found }
I'm closing this issue. It's working as expected.
- addedapi: datastoreIssues related to the Datastore API.Issues related to the Datastore API.
on Feb 2, 2015 - addedtriage meI really want to be triaged.I really want to be triaged.🚨This issue needs some love.This issue needs some love.
on Apr 6, 2020 71 remaining items
- added a commit that references this issue
on Mar 5, 2026 - added 5 commits that reference this issue
on Mar 5, 2026 - added 2 commits that reference this issue
on Mar 9, 2026 - added 2 commits that reference this issue
on Mar 12, 2026 - added 2 commits that reference this issue
on Mar 23, 2026 - added a commit that references this issue
on Mar 27, 2026
Currently
datastore.getwould return `callback(null #error, undefined #key, undefined #entity), when entity is not found.I think it would be more useful for the developer to provide a more explicit hint that the entity was not found (either through a dedicated error or some more structured result value).
As a reference the underlying RPC returns
foundandmissingarrays.