Skip to content

Datastore query and get don't return entity data, only data object #1724

Description

@schliffer

Environment details

  • OS: Goobuntu Linux/GCE
  • Node.js version: 4.6.0
  • npm version: 2.15.9
  • google-cloud-node version: 0.5.0

Steps to reproduce

Trying to use @google-cloud/datastore as part of a project. When querying the datastore, the data returned is only the data, and does not contain the key/id. For example the following code:

'use strict';

var Datastore = require('@google-cloud/datastore');

var ds = Datastore({
  projectId: 'my-project'
});

var dataservice = {};

dataservice.getFirstGame = function() {
  var query = ds.createQuery('Game').limit(1);
  ds.runQuery(query, (err, entities) => {
    console.log(err || entities);
  });
};

dataservice.getFirstGame();

Logs

[ { TeamTwo: [ 'player2' ],
    TeamOne: [ 'player1' ],
    LeagueId: 'somestring',
    GameResult: 1,
    DatePlayed: Tue Oct 18 2016 12:31:05 GMT-0700 (PDT) } ]

The documentation indicates that the entities should be an array of objects that each has the key and data object. We're not getting either of those, it looks like we're just getting an array of only the data objects.

We need the key/id in order to later update the object in the datastore.

Thanks!

Activity

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

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions