GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Access properties directly from the entity · Issue #508 · googleapis/google-cloud-node

Access properties directly from the entity #508

New issue
Copy link
New issue
Copy link
Closed
Closed
Access properties directly from the entity#508
Copy link
Assignees
yoshi-automation
Labels
api: datastoreIssues related to the Datastore API.

Description

@pcostell
pcostell
opened on Apr 21, 2015
Issue body actions

When modifying or accessing entity properties, consistently you have to step into the data property:

my_entity.data.my_property
my_entity.data.my_other_property

Compare this to the other gcloud datastore APIs:

Python:

my_entity['my_property']

Ruby:

my_entity[:my_property]

It would be nice if properties could be accessed on the entity directly.

Activity

Next
  1. pcostell
    added
    api: datastoreIssues related to the Datastore API.
    on Apr 21, 2015
  2. ryanseys commented on Apr 27, 2015

    @ryanseys
    ryanseys
    on Apr 27, 2015
    Contributor
    More actions

    Seems our entities are comprised of key and data properties, so that the user can access their key value by going entity.key instead of entity.__key__ I believe. I'd suspect we'd have to change that if we wanted all the properties to be on the first level of the entity object like you described. Unless we wanted to potentially clobber entity.key but I believe key is not a reserved value as far as datastore is concerned, only __key__ is reserved.

  3. jgeewax
    added
    enhancement
    on Apr 30, 2015
  4. jgeewax commented on Apr 30, 2015

    @jgeewax
    jgeewax
    on Apr 30, 2015
    Contributor
    More actions

    I think the issue comes specifically because Javascript doesn't allow you to differentiate between a method (entity.key()), a property (entity.key), and an attribute (entity['key']) -- as far as JS is concerned, it's all the same thing.

    One option would be to add a getter method for the key (entity.getKey()) as a shortcut for the __key__ attribute.

    This doesn't address the issue where things could be blasted out (ie, getKey as a property in Datastore would be blasted out by the getKey method), so if we do something like this we'd need to also expose the "raw data" on the entity object as well.

    In short though, I think the common case will be "very few people will have a property called getKey" -- we should optimize for that and allow people "go the long way" (ie, entity.data.getKey) if they are uncommon enough to name a property as that. (Note that apparently property names are allowed to have spaces -- and even start with spaces -- so there will be edge cases that we should make possible but not easy.)

    @ryanseys What do you think?

  5. jgeewax
    added this to the Datastore Future milestone on Apr 30, 2015
  6. ryanseys commented on Apr 30, 2015

    @ryanseys
    ryanseys
    on Apr 30, 2015
    Contributor
    More actions

    This sounds like a job well-suited for Proxies! Unfortunately Node doesn't universally support those. I think we might be able to get around this by attaching a special getter and setter to the getKey property of the entity object that detects when it's reassigned, and properly diverts the reassignment to the underlying property... I'll see what I can think up.

  7. stephenplusplus commented on Oct 10, 2016

    @stephenplusplus
    stephenplusplus
    on Oct 10, 2016
    Contributor
    More actions

    Gave this a shot using a Symbol as a key: #1682

  8. stephenplusplus
    modified the milestones: This milestone has been deleted, Datastore Future on Oct 10, 2016
  9. callmehiphop
    closed this as completedin #1682on Oct 14, 2016
  10. JustinBeckwith
    assigned
    yoshi-automation
    on Feb 1, 2021
  11. chingor13
    added 3 commits that reference this issue on Aug 22, 2022

    chore: release 3.14.1 (#508)

    6bbf202

    chore: release 3.14.1 (#508)

    5d9862e

    chore: release 3.14.1 (#508)

    32e3885
  12. sofisl
    added a commit that references this issue on Sep 15, 2022

    fix(deps): google-gax v2.24.1 (#508)

    660d76c
  13. 33 remaining items

  14. sofisl
    added 3 commits that reference this issue on Jan 27, 2026

    build: set correct src path for template (#508)

    941a836

    build: set correct src path for template (#508)

    a25199e

    build: set correct src path for template (#508)

    d2347d1
  15. GautamSharda
    added a commit that references this issue on Feb 2, 2026

    test: upstream serialization issues breaking library (#508)

    3f27049
  16. sofisl
    added a commit that references this issue on Feb 3, 2026

    fix(deps): update dependency @google-cloud/storage to v3 (#508)

    6a20053
  17. GautamSharda
    added a commit that references this issue on Feb 3, 2026

    test: upstream serialization issues breaking library (#508)

    b51a999
  18. sofisl
    added a commit that references this issue on Feb 4, 2026

    docs: add instructions for authenticating for system tests (#508)

    108259a
  19. GautamSharda
    added a commit that references this issue on Feb 5, 2026

    chore: update cloud rad kokoro build job (#508)

    db9b3d5
  20. GautamSharda
    added 2 commits that reference this issue on Feb 23, 2026

    chore: update cloud rad kokoro build job (#508)

    8ffe02f

    chore: update cloud rad kokoro build job (#508)

    1a3af56
  21. sofisl
    added a commit that references this issue on Feb 26, 2026

    refactor(types): enable noImplicitAny in session-pool.ts (#508)

    a85d117
  22. GautamSharda
    added a commit that references this issue on Mar 5, 2026

    build: remove unused clang format (#508)

    c3588f0
  23. sofisl
    added a commit that references this issue on Mar 5, 2026

    chore!: update library to Node 18 (#508)

    c2d3995
  24. GautamSharda
    added 2 commits that reference this issue on Mar 11, 2026

    refactor(ts): enable noImplicitAny for lease-manager test file (#508)

    eba69ad

    docs: update jsdoc license/samples-README (#508)

    071d335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @yoshi-automation
    yoshi-automation

Labels

api: datastoreIssues related to the Datastore API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.