Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datastore: Filter a query on a key #73

Closed
temsa opened this issue Jul 31, 2014 · 8 comments
Closed

datastore: Filter a query on a key #73

temsa opened this issue Jul 31, 2014 · 8 comments
Assignees
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@temsa
Copy link

temsa commented Jul 31, 2014

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

@silvolu
Copy link
Contributor

silvolu commented Jul 31, 2014

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

@pcostell
Copy link
Contributor

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 notifications@github.com
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)
.

@silvolu
Copy link
Contributor

silvolu commented Jul 31, 2014

@pcostell thanks, now I understand :)

@rakyll
Copy link
Contributor

rakyll commented Jul 31, 2014

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.

@temsa
Copy link
Author

temsa commented Jul 31, 2014

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.

@rakyll
Copy link
Contributor

rakyll commented Jul 31, 2014

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.

@rakyll rakyll changed the title How can we filter a query on a key datastore: Filter a query on a key Jul 31, 2014
@temsa
Copy link
Author

temsa commented Jul 31, 2014

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 ?

@rakyll rakyll added this to the M1: core, datastore & storage milestone Aug 5, 2014
@rakyll
Copy link
Contributor

rakyll commented Aug 8, 2014

Fixed by #106.

@rakyll rakyll closed this as completed Aug 8, 2014
@jgeewax jgeewax added the api: datastore Issues related to the Datastore API. label Feb 2, 2015
@jgeewax jgeewax modified the milestones: M1: core, datastore & storage, Datastore Stable Feb 2, 2015
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 7, 2020
chingor13 pushed a commit that referenced this issue Aug 22, 2022
* build: add Kokoro configs for autorelease

* build: add Kokoro configs for autorelease

* chore: remove CircleCI config
sofisl pushed a commit that referenced this issue Sep 16, 2022
sofisl pushed a commit that referenced this issue Oct 5, 2022
sofisl pushed a commit that referenced this issue Oct 8, 2022
sofisl pushed a commit that referenced this issue Nov 11, 2022
fix!: `update_mask` field is required for all Update operations
feat: add pagination support for `ListFirebaseLinks` operation
fix!: rename `country_code` field to `region_code` in `Account`
fix!: rename `url_query_parameter` field to `uri_query_parameter` in `EnhancedMeasurementSettings`
fix!: remove `parent` field from `GoogleAdsLink` (#73)

PiperOrigin-RevId: 351651504
Source-Author: Google APIs <noreply@google.com>
Source-Date: Wed Jan 13 13:18:19 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 23e7356f4cf449d6e9977698c5d9383b566be7af
Source-Link: googleapis/googleapis@23e7356
sofisl pushed a commit that referenced this issue Nov 11, 2022
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [sinon](https://sinonjs.org/) ([source](https://github.com/sinonjs/sinon)) | [`^12.0.0` -> `^13.0.0`](https://renovatebot.com/diffs/npm/sinon/12.0.1/13.0.1) | [![age](https://badges.renovateapi.com/packages/npm/sinon/13.0.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/sinon/13.0.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/sinon/13.0.1/compatibility-slim/12.0.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/sinon/13.0.1/confidence-slim/12.0.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>sinonjs/sinon</summary>

### [`v13.0.1`](https://github.com/sinonjs/sinon/blob/HEAD/CHANGES.md#&#8203;1301)

[Compare Source](https://github.com/sinonjs/sinon/compare/v13.0.0...v13.0.1)

-   [`ec4223f9`](https://github.com/sinonjs/sinon/commit/ec4223f94076d809483e3c6a7536cfc1278dd3c9)
    Bump nise to fix [sinonjs/nise#&#8203;193](https://github.com/sinonjs/nise/issues/193) (Carl-Erik Kopseng)
-   [`f329a010`](https://github.com/sinonjs/sinon/commit/f329a01040bfa5a79e039419220b21eda56935d6)
    Add unimported to workflow ([#&#8203;2441](https://github.com/sinonjs/sinon/issues/2441)) (Morgan Roderick)
-   [`7f16cec9`](https://github.com/sinonjs/sinon/commit/7f16cec968c3c8d4e580267fb00195916d6f827d)
    Enable updates to same major version (Carl-Erik Kopseng)
-   [`f784d7ad`](https://github.com/sinonjs/sinon/commit/f784d7ad2c86be0fc65477d69f8bdafca846ef2c)
    Re-introduce new version.sh script to version hook (Joel Bradshaw)
    > This was inadvertently removed during merge conflicts, and is required
    > for any of the new release process stuff to work
-   [`51c508ab`](https://github.com/sinonjs/sinon/commit/51c508ab77cf0f9fb8c5305ff626f6a2eada178f)
    Add dry run mode to `npm version` ([#&#8203;2436](https://github.com/sinonjs/sinon/issues/2436)) (Joel Bradshaw)
    > -   Add DRY_RUN flag to skip publish/push
    >
    > -   Allow overriding branch names for testing
-   [`05341dcf`](https://github.com/sinonjs/sinon/commit/05341dcf92ddca4a1d4c90966b1fcdc7039cff18)
    Update npm version scripts to manage new releases branch (Joel Bradshaw)
-   [`fe658261`](https://github.com/sinonjs/sinon/commit/fe65826171db69ed2986a1060db77944dbc98a6d)
    Remove release archives from master (Joel Bradshaw)
    > These archives made it difficult to find things in the GitHub interface,
    > and take up a lot of space in a checked-out repo for something that is
    > not useful to most people checking out the repository.
    >
    > The main purpose of these archives is to make old versions and
    > documentation available on the Sinon website that is run out of this
    > repo. This can be supported by using a separate branch for website
    > releases, and to maintain the archives.
    >
    > Following this commit, the `npm version` scripts will be updated to
    > automatically handle archiving the releases in the new releases branch
    > and keeping it up to date with master.
    >
    > Also remove the directories we removed from .prettierignore, since they
    > don't exist any more.

*Released by [Carl-Erik Kopseng](https://github.com/fatso83) on 2022-02-01.*

### [`v13.0.0`](https://github.com/sinonjs/sinon/blob/HEAD/CHANGES.md#&#8203;1300)

[Compare Source](https://github.com/sinonjs/sinon/compare/v12.0.1...v13.0.0)

-   [`cf3d6c0c`](https://github.com/sinonjs/sinon/commit/cf3d6c0cd9689c0ee673b3daa8bf9abd70304392)
    Upgrade packages ([#&#8203;2431](https://github.com/sinonjs/sinon/issues/2431)) (Carl-Erik Kopseng)
    > -   Update all @&#8203;sinonjs/ packages
    >
    > -   Upgrade to fake-timers 9
    >
    > -   chore: ensure always using latest LTS release
-   [`41710467`](https://github.com/sinonjs/sinon/commit/417104670d575e96a1b645ea40ce763afa76fb1b)
    Adjust deploy scripts to archive old releases in a separate branch, move existing releases out of master ([#&#8203;2426](https://github.com/sinonjs/sinon/issues/2426)) (Joel Bradshaw)
    > Co-authored-by: Carl-Erik Kopseng <carlerik@gmail.com>
-   [`c80a7266`](https://github.com/sinonjs/sinon/commit/c80a72660e89d88b08275eff1028ecb9e26fd8e9)
    Bump node-fetch from 2.6.1 to 2.6.7 ([#&#8203;2430](https://github.com/sinonjs/sinon/issues/2430)) (dependabot\[bot])
    > Co-authored-by: dependabot\[bot] <49699333+dependabot\[bot][@&#8203;users](https://github.com/users).noreply.git.luolix.top>
-   [`a00f14a9`](https://github.com/sinonjs/sinon/commit/a00f14a97dbe8c65afa89674e16ad73fc7d2fdc0)
    Add explicit export for `./*` ([#&#8203;2413](https://github.com/sinonjs/sinon/issues/2413)) (なつき)
-   [`b82ca7ad`](https://github.com/sinonjs/sinon/commit/b82ca7ad9b1add59007771f65a18ee34415de8ca)
    Bump cached-path-relative from 1.0.2 to 1.1.0 ([#&#8203;2428](https://github.com/sinonjs/sinon/issues/2428)) (dependabot\[bot])
-   [`a9ea1427`](https://github.com/sinonjs/sinon/commit/a9ea142716c094ef3c432ecc4089f8207b8dd8b6)
    Add documentation for assert.calledOnceWithMatch ([#&#8203;2424](https://github.com/sinonjs/sinon/issues/2424)) (Mathias Schreck)
-   [`1d5ab86b`](https://github.com/sinonjs/sinon/commit/1d5ab86ba60e50dd69593ffed2bffd4b8faa0d38)
    Be more general in stripping off stack frames to fix Firefox tests ([#&#8203;2425](https://github.com/sinonjs/sinon/issues/2425)) (Joel Bradshaw)
-   [`56b06129`](https://github.com/sinonjs/sinon/commit/56b06129e223eae690265c37b1113067e2b31bdc)
    Check call count type ([#&#8203;2410](https://github.com/sinonjs/sinon/issues/2410)) (Joel Bradshaw)
-   [`7863e2df`](https://github.com/sinonjs/sinon/commit/7863e2dfdbda79e0a32e42af09e6539fc2f2b80f)
    Fix [#&#8203;2414](https://github.com/sinonjs/sinon/issues/2414): make Sinon available on homepage (Carl-Erik Kopseng)
-   [`fabaabdd`](https://github.com/sinonjs/sinon/commit/fabaabdda82f39a7f5b75b55bd56cf77b1cd4a8f)
    Bump nokogiri from 1.11.4 to 1.13.1 ([#&#8203;2423](https://github.com/sinonjs/sinon/issues/2423)) (dependabot\[bot])
-   [`dbc0fbd2`](https://github.com/sinonjs/sinon/commit/dbc0fbd263c8419fa47f9c3b20cf47890a242d21)
    Bump shelljs from 0.8.4 to 0.8.5 ([#&#8203;2422](https://github.com/sinonjs/sinon/issues/2422)) (dependabot\[bot])
-   [`fb8b3d72`](https://github.com/sinonjs/sinon/commit/fb8b3d72a85dc8fb0547f859baf3f03a22a039f7)
    Run Prettier (Carl-Erik Kopseng)
-   [`12a45939`](https://github.com/sinonjs/sinon/commit/12a45939e9b047b6d3663fe55f2eb383ec63c4e1)
    Fix 2377: Throw error when trying to stub non-configurable or non-writable properties ([#&#8203;2417](https://github.com/sinonjs/sinon/issues/2417)) (Stuart Dotson)
    > Fixes issue [#&#8203;2377](https://github.com/sinonjs/sinon/issues/2377) by throwing an error when trying to stub non-configurable or non-writable properties

*Released by [Carl-Erik Kopseng](https://github.com/fatso83) on 2022-01-28.*

</details>

---

### Configuration

📅 **Schedule**: "after 9am and before 3pm" (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-essential-contacts).
sofisl pushed a commit that referenced this issue Nov 11, 2022
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 408439482

Source-Link: googleapis/googleapis@b9f6184

Source-Link: googleapis/googleapis-gen@eb888bc
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWI4ODhiYzIxNGVmYzdiZjQzYmY0NjM0YjQ3MDI1NDU2NWE2NTlhNSJ9
sofisl pushed a commit that referenced this issue Nov 16, 2022
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@types/sinon](https://github.com/DefinitelyTyped/DefinitelyTyped) | [`^9.0.4` -> `^10.0.0`](https://renovatebot.com/diffs/npm/@types%2fsinon/9.0.11/10.0.0) | [![age](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/compatibility-slim/9.0.11)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@types%2fsinon/10.0.0/confidence-slim/9.0.11)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

:date: **Schedule**: "after 9am and before 3pm" (UTC).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-bigquery-connection).
sofisl pushed a commit that referenced this issue Nov 16, 2022
…ript generator. (#73)

Also removing the explicit generator tag for the IAMPolicy mixin for the kms and pubsub APIS as the generator will now read it from the .yaml file.

PiperOrigin-RevId: 385101839

Source-Link: googleapis/googleapis@80f4042

Source-Link: googleapis/googleapis-gen@d3509d2
sofisl pushed a commit that referenced this issue Nov 17, 2022
Delete tests for sendgrid and mailjet.
Add vms_api to the list of samples.

Add descriptions, fix sample code, and fix broken links
sofisl pushed a commit that referenced this issue Nov 30, 2022
* updated CHANGELOG.md [ci skip]

* updated package.json [ci skip]

* updated samples/package.json [ci skip]

Co-authored-by: Alexander Fenster <github@fenster.name>
sofisl pushed a commit that referenced this issue Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

6 participants