Skip to content

datastore.get should handle entity not found better #10

Description

@proppy

Currently 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.

Activity

  1. rakyll commented on Jul 14, 2014

    @rakyll
    Contributor

    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).

  2. proppy commented on Jul 14, 2014

    @proppy
    ContributorAuthor

    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.

  3. rakyll commented on Jul 14, 2014

    @rakyll
    Contributor

    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
    }
  4. reopened this on Jul 14, 2014
  5. rakyll commented on Jul 21, 2014

    @rakyll
    Contributor

    I'm closing this issue. It's working as expected.

  6. modified the milestones: , Datastore Stable on Feb 2, 2015
  7. 71 remaining items

  8. added a commit that references this issue on Feb 4, 2026
  9. added a commit that references this issue on Feb 26, 2026
  10. added a commit that references this issue on Mar 5, 2026
  11. added 2 commits that reference this issue on Mar 23, 2026
    02dc37f
    d8018c6
  12. added a commit that references this issue on Mar 27, 2026
    d34b917
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: datastoreIssues related to the Datastore API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions