GeezerVison is showing github.com — datastore.get should handle entity not found better · Issue #10 · googleapis/google-cloud-node
datastore.get should handle entity not found better #10DescriptionCurrently datastore.get would 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 found and missing arrays. Activityrakyll commented on Jul 14, 2014 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). proppy commented on Jul 14, 2014 ContributorAuthor More actions maybe cb(null, null, null) would be more appropriate that cb(null, undefined, undefined).
I'm not sure what nodejs developer expect for empty result, what seems weird in my case is that I can undefined as the result even if my lookup RPC is valid. rakyll commented on Jul 14, 2014 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
}rakyll commented on Jul 21, 2014 I'm closing this issue. It's working as expected. added 2 commits that reference this issue on Mar 23, 2026Fix #10 Implement read-rows-acceptance-test (#22) This issue will close once commit 02dc37f is merged into the 'main' branch.02dc37f Fix #10 Implement read-rows-acceptance-test (#22) This issue will close once commit d8018c6 is merged into the 'main' branch.d8018c6 added a commit that references this issue on Mar 27, 2026Fix #10 Implement read-rows-acceptance-test (#22) This issue will close once commit d34b917 is merged into the 'main' branch.d34b917
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|