0
votes

I am trying to run the following GQL query:

function gqlExample(callback) {
  datastore.runQuery({
    gqlQuery: {
      queryString: 'SELECT * FROM Person',
    }
  }).execute(function(err, result) {
    if (!err) {
      // Iterate over the results and return the entities.
      result = (result.batch.entityResults || []).map(
        function(entityResult) {
          return entityResult.entity;
        });
    }
    callback(err, result);
  });
}

I found the above example on the following page: http://ec2-54-66-129-240.ap-southeast-2.compute.amazonaws.com/httrack/docs/cloud.google.com/datastore/docs/concepts/gql.html

It states that it is a valid node.js example but on running the query I get the following error:

/Users/xxxx/relay-fullstack/server/data/campaign-datastore.js:245
  }).execute(function (err, result) {
     ^
TypeError: ds.runQuery(...).execute is not a function
    at Object.campaignSearchGql (campaign-datastore.js:265:6)
    at Test.<anonymous> (datastore-test.js:29:16)
    at Test.bound [as _cb] (/Users/xxxx/relay-fullstack/node_modules/tape/lib/test.js:63:32)
    at Test.run (/Users/xxxx/relay-fullstack/node_modules/tape/lib/test.js:82:10)
    at Test.bound [as run] (/Users/xxxx/relay-fullstack/node_modules/tape/lib/test.js:63:32)
    at Immediate.next [as _onImmediate] (/Users/xxxx/relay-fullstack/node_modules/tape/lib/results.js:70:15)
    at tryOnImmediate (timers.js:534:15)
    at processImmediate [as _immediateCallback] (timers.js:514:5)

I am using the latest version of google cloud for node:

"google-cloud": "^0.38.3",

Has anyone got GQL queries executing correctly with gcloud and node? Any help will be greatly appreciated.

1

1 Answers

2
votes

That is apparently a cached version of the Datastore docs. Those Node.js snippets are using a different library called googleapis: https://github.com/google/google-api-nodejs-client

The other library, gcloud-node, doesn't support GQL at this time.