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 — datastore: Filter a query on a key · Issue #73 · googleapis/google-cloud-node

datastore: Filter a query on a key #73

New issue
Copy link
New issue
Copy link
Closed
Closed
datastore: Filter a query on a key#73
Copy link
Assignees
rakyll
Labels
🚨This issue needs some love.api: datastoreIssues related to the Datastore API.triage meI really want to be triaged.
Milestone
Datastore Stable

Description

@temsa
temsa
opened on Jul 31, 2014
Issue body actions

Hi !

We're pretty much in a hurry for now, hoping we will find some pretty live support here, so I'm quoting your name with hope it will help (sorry for that) : @silvolu @pcostell @rakyll

First, we had trouble with using the json key in 0.0.6 so we got back to pem file with version 0.0.5. But this is not about this issue.

We want to filter according to a non-ancestor Key. We have tried several things.

The naive one :

var q = ds.createQuery('Plop').limit(5).filter('fooAccountKey =', ['Mykind', 1243567])

It didn't work (Array not supported).

We then tried a more complicated one, looking at https://github.com/GoogleCloudPlatform/gcloud-node/blob/master/test/datastore.entity.js#L295 :

var q = ds.createQuery('Plop').limit(5).filter('fooAccountKey =', {
  partitionId: {
    datasetId: 's-my-app',
    namespace: ''
  },
  path: {
    kind: 'Mykind',
    id: '1243567'
  }
});

We are currently trying with a more "raw" request, using your tests for some help, still we don't get yet how to run a raw request directly ; we tried raw request with ds.runQuery(query).execute(), but no luck yet, maybe our raw request is not good yet

Keep up the good job, we'll probably contribute by our own soon :)

Activity

Next
  1. silvolu commented on Jul 31, 2014

    @silvolu
    silvolu
    on Jul 31, 2014
    Contributor
    More actions

    @temsa are you trying to filter by key?
    If so, var q = ds.createQuery('Plop').limit(5).filter('__key__ =', ['Mykind', 1243567]); should be what you're looking for.

    Reacted by Gökçe Dilek
  2. pcostell commented on Jul 31, 2014

    @pcostell
    pcostell
    on Jul 31, 2014
    Contributor
    More actions

    In Datastore it is also possible to store keys as properties and then
    filter on them. It looks like this currently is not possible.

    On Thu, Jul 31, 2014 at 10:39 AM, Silvano Luciani [email protected]
    wrote:

    @temsa https://github.com/temsa are you trying to filter by key
    https://developers.google.com/datastore/docs/concepts/queries#Datastore_Key_filters
    ?
    If so, var q = ds.createQuery('Plop').limit(5).filter('key =',
    ['Mykind', 1243567]); should be what you're looking for.

    —
    Reply to this email directly or view it on GitHub
    #73 (comment)
    .

  3. silvolu commented on Jul 31, 2014

    @silvolu
    silvolu
    on Jul 31, 2014
    Contributor
    More actions

    @pcostell thanks, now I understand :)

  4. rakyll commented on Jul 31, 2014

    @rakyll
    rakyll
    on Jul 31, 2014
    Contributor
    More actions

    It looks like this currently is not possible.

    Yes, #39 needs to be resolved as well and keys are represented as plain arrays, we need an explicit type to be able to convert a plain object to Entity proto. If there is an embedded key, I don't know whether it's a plain array or a key. So we need some boxing for keys, the way we've done it for Integer and Double types.

  5. temsa commented on Jul 31, 2014

    @temsa
    temsa
    on Jul 31, 2014
    Author
    More actions

    We finally found a temporary solution, I have not the code under the eyes, but using google datastore api for node.js documentation, the unit tests and the code itself, we could create a raw request by our own, using GQL to ease creation, then use ds.transaction.makeReq to send it with auth.

    It's defintively not elegant, yet it works, and we could do what we had to in the very short timeframe we had (dumping some parts of the datastore according to some filters, including keys) thanks to this lib 👍

    Thank you all for your quick answers :)

    By the way, #39 is effectively important. Boxing is a way to do it, yet a more implicit way could be done using simply duck typing and/or variable arguments/arity : keys seems the only primitive that is composed of an infinite list of string / long pairs 👍

    var q = ds.createQuery('Plop').limit(5).filter('myKey =', 'Mykind', 1243567) could totally work, var q = ds.createQuery('Plop').limit(5).filter('myKey =', 'Mykind', 1243567, 'MyAncestorKind', 123), too, etc.

    Yet boxing can be sometime practical if not too verbose : var q = ds.createQuery('Plop').limit(5).filter('myKey =', Key('Mykind', 1243567)) would do the trick too. Note that supporting both API could be possible at the same time.

  6. rakyll commented on Jul 31, 2014

    @rakyll
    rakyll
    on Jul 31, 2014
    Contributor
    More actions

    keys seems the only primitive that is composed of an infinite list of string / long pairs

    We can't depend on that. Arbitrary entities can have list of string, long pairs as data. Boxing will not be verbose. Something similar to ds.key('Kind', 123) as your proposed.

  7. rakyll
    changed the title [-]How can we filter a query on a key[/-] [+]datastore: Filter a query on a key[/+] on Jul 31, 2014
  8. temsa commented on Jul 31, 2014

    @temsa
    temsa
    on Jul 31, 2014
    Author
    More actions

    Arbitrary entities can have list of string

    Yet they could be expressed as Arrays, while Keys could be expressed as vararg or ds.key.

    Concerning ds.key, maybe ds.Key would be better, so you can do a var Key = ds.Key and use Key as you would have done in a GQL query. You could do it with ds.key too, yet it would seem less natural for a developer.

    So, a ds.Key object would be fine for explicit boxing, with the constructor serving as a factory so Key(...) would be equivalent to new Key(...), so the boxing would still be light to write for the developer.

    What do you think ?

  9. rakyll
    added this to the This milestone has been deleted milestone on Aug 5, 2014
  10. rakyll commented on Aug 8, 2014

    @rakyll
    rakyll
    on Aug 8, 2014
    Contributor
    More actions

    Fixed by #106.

  11. rakyll
    closed this as completedon Aug 8, 2014
  12. jgeewax
    added
    api: datastoreIssues related to the Datastore API.
    on Feb 2, 2015
  13. jgeewax
    modified the milestones: This milestone has been deleted, Datastore Stable on Feb 2, 2015
  14. 85 remaining items

  15. GautamSharda
    added 2 commits that reference this issue on Feb 25, 2026

    fix: handle fallback option properly (#73)

    d923897

    chore: release 2.1.0 (#72)

    e6a55d0
  16. sofisl
    added 5 commits that reference this issue on Feb 26, 2026

    0.10.0 (#73)

    f539d92

    Jsdoc region tag migration (#52)

    ebebe7a

    fix: lint and docs scripts (#73)

    9ee6c8c

    chore: Retry request migration (#858)

    6dcb8a6

    chore: ignore package-lock.json (#73)

    bad58fc
  17. GautamSharda
    added 3 commits that reference this issue on Mar 12, 2026

    fix(build): fix Kokoro release script (#73)

    ab3b738

    fix(build): fix Kokoro release script (#73)

    b7885aa

    chore: remove array-uniq (#73)

    771f24f
  18. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    Fixes googleapis#43 (googleapis#73)

    e149f43
  19. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    chore: one more workaround for repo-tools EPERM (#73)

    fa47863

    chore: one more workaround for repo-tools EPERM (#73)

    e50eb6a
  20. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    chore: one more workaround for repo-tools EPERM (#73)

    72eb446
  21. thiyaguk09
    added a commit that references this issue on May 5, 2026

    chore: one more workaround for repo-tools EPERM (googleapis#73)

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

Metadata

Metadata

Assignees

  • @rakyll
    rakyll

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

    Milestone

    • Datastore Stable

    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.