GeezerVison is showing github.com — @google-cloud/datastore 0.5.0 does not return entity keys with query results · Issue #250 · GoogleCloudPlatform/nodejs-docs-samples
@google-cloud/datastore 0.5.0 does not return entity keys with query results #250Labels 🚨This issue needs some love.triage meI really want to be triaged. DescriptionFrom @floodfx on November 9, 2016 16:40
Environment details
- OS: MacOS 10.11.6
- Node.js version: 6.9.1
- npm version: 3.10.8
- google-cloud-node version: 0.43.0
- @google-cloud/datastore version: 0.5.0
Steps to reproduce
git clone [email protected]:GoogleCloudPlatform/nodejs-docs-samples.git
cd nodejs-docs-samples/datastore
Open quickstart.js
Add code below to end of the file
// query for entities
var q = datastoreClient.createQuery(kind)
q.run((err, entities, nextQuery) => {
console.log(err, entities, nextQuery)
for(var i = 0; i < entities.length; i++) {
var task = entities[i];
console.log(`Task ${task}: Key${task.key}`);
}
});
Run
npm install
node quickstart.js
Keys returned with entity results.
Next update package.json to use 0.5.0 of @google-cloud/datastore
Run
Keys are "undefined".
Copied from original issue: googleapis/google-cloud-node#1780 Activitystephenplusplus commented on Nov 9, 2016 ContributorAuthor More actions From @floodfx on November 9, 2016 16:42
Note the default version of @google-cloud/datastore for nodejs-docs-samples is "^0.1.1" stephenplusplus commented on Nov 9, 2016 ContributorAuthor More actions Thanks for reporting, @floodfx!
An entity structures its data differently now, not embedding the Key within the object:
datastore.get(key, function(error, entity) {
// Before:
entity.key = Key object
entity.data = {...data...}
// After:
entity = {...data...}
entity[datastore.KEY] = Key object
});
See googleapis/google-cloud-node#1768 for more details. floodfx commented on Nov 9, 2016 Thanks @stephenplusplus. appreciate the link. figured I was missing something obvious. Do you know where this is mentioned in the official docs? I spent a lot of time trying to figure this out before trying a different version. Happy to send a PR on docs if that'd be helpful? stephenplusplus commented on Nov 9, 2016 ContributorAuthor More actions I'm really sorry about that :( I think we've caught all of the examples in the docs, but they won't update until we cut a new release. If you browse the master docs, you'll see the corrected examples.
Thank you very much for being patient and offering your help! jmdobry commented on Nov 9, 2016 I actually just fixed all of the Datastore samples in this repo to use 0.5.0, the PR is pending review: #249 added 2 commits that reference this issue on Nov 18, 2016This issue will close once commit dbb186a is merged into the 'main' branch.dbb186a This issue will close once commit ed81bc1 is merged into the 'main' branch.ed81bc1 puppetmaster3 commented on Feb 28, 2017 Does not work, I tried the new way, and you can't get the key back via query. czzarr commented on Mar 2, 2017 How do you get the key on the front-end without the datastore dependency? added a commit that references this issue on Nov 10, 2022This issue will close once commit 5036529 is merged into the 'main' branch.5036529
MetadataMetadata🚨This issue needs some love.triage meI really want to be triaged. DevelopmentNo branches or pull requestsIssue actions
|