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

datatstore: Provide a way to get the generated ID from a Key object #171

Closed
rakyll opened this issue Sep 3, 2014 · 6 comments
Closed

datatstore: Provide a way to get the generated ID from a Key object #171

rakyll opened this issue Sep 3, 2014 · 6 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

@rakyll
Copy link
Contributor

rakyll commented Sep 3, 2014

var key = ds.key('Kind', null)
ds.put({
  key: key,
  data: //...
}, function(err, key) {
   /// how to i read the key ID?
});
@stephenplusplus
Copy link
Contributor

Any thoughts for how to provide this? An id property on the Key object? Exposing a getId method to return the last item in the path array (would that even work?)?

This also got me thinking. Well, 1: we don't have a put method, but I assume you meant save :) And 2: if it's not too much magic, we could update the key object reference passed in to save, as opposed to only returning a new key object in the callback. The callback would behave as it currently does, but would also update the original key object.

If you have an idea for an implementation, I'm happy to give it a shot.

@rakyll
Copy link
Contributor Author

rakyll commented Sep 4, 2014

Exposing a getId method to return the last item in the path array (would that even work?)?

This would work.

But we should additionally provide a pseudo getter for the full path as well. Parent entity keys should be recoverable as well.

The callback would behave as it currently does, but would also update the original key object.

This doesn't fix the problem of not being able to read the ID. You would like to use the ID somewhere else (e.g. as a key to memcache or on the URL to the item's detail page).

We should at least have a getId and getPath before the release.

@rakyll
Copy link
Contributor Author

rakyll commented Sep 4, 2014

@stephenplusplus
Copy link
Contributor

This doesn't fix the problem of not being able to read the ID.

Nope, was just to be a convenience, since currently you would be left with 2 keys that were meant to refer to the same thing. I'll give it a shot, then run it by you via PR.

stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 4, 2014
@stephenplusplus
Copy link
Contributor

#175 should fix this issue. I'll work on the second part soon.

@stephenplusplus
Copy link
Contributor

It sounds like we decided against providing this feature. The link to @proppy's code shows how you can get the id:

key.path_.pop(); // possibly `key.path.pop()` soon.

Re-open if I was mistaken, and this feature can be achieved reliably.

@jgeewax jgeewax added api: datastore Issues related to the Datastore API. enhancement labels Feb 2, 2015
@jgeewax jgeewax added this to the Datastore Stable milestone Feb 2, 2015
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 6, 2020
sofisl pushed a commit that referenced this issue Nov 11, 2022
)

feat: generating GAPIC libraries for Google Cloud Functions v2alpha
PiperOrigin-RevId: 454899846
Source-Link: googleapis/googleapis@7088e38
Source-Link: googleapis/googleapis-gen@c3673f8
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzM2NzNmODkyYzgwM2I5YzNmMTc4NDFiY2RlZTdkYjZiMzE3OTQ0NCJ9
PiperOrigin-RevId: 454900284
Source-Link: googleapis/googleapis@05576c8
Source-Link: googleapis/googleapis-gen@5b2f0e3
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNWIyZjBlMzZkMjdhYTU4ZmJkZTE1ZDFlN2FiNzEzOGNmNWVhODM3YSJ9
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 11, 2022
* chore(main): release 3.1.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 11, 2022
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/9b1f5306-e1f1-4834-baa7-c436ccd06c13/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@5451633
sofisl pushed a commit that referenced this issue Nov 11, 2022
This PR includes changes from googleapis/gapic-generator-typescript#317
that will move the asynchronous initialization and authentication from the client constructor
to an `initialize()` method. This method will be automatically called when the first RPC call
is performed.

The client library usage has not changed, there is no need to update any code.

If you want to make sure the client is authenticated _before_ the first RPC call, you can do
```js
await client.initialize();
```
manually before calling any client method.
sofisl pushed a commit that referenced this issue Nov 11, 2022
[PR](googleapis/gapic-generator-typescript#878) within
updated gapic-generator-typescript version 1.4.0

Committer: @summer-ji-eng
PiperOrigin-RevId: 375759421

Source-Link: googleapis/googleapis@95fa72f

Source-Link: googleapis/googleapis-gen@f40a343
sofisl pushed a commit that referenced this issue Nov 16, 2022
sofisl pushed a commit that referenced this issue Nov 17, 2022
* Use PATCH semantics by default to set custom metadata

This changes the default behavior from `POST` to `PATCH` so that the
custom metadata passed into `VM#setMetadata` augments what is already
set.
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

4 participants