【问题标题】:GQL queries not working using gcloud (google-cloud) and node.jsGQL 查询无法使用 gcloud (google-cloud) 和 node.js
【发布时间】:2016-08-12 09:49:19
【问题描述】:

我正在尝试运行以下 GQL 查询:

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);
  });
}

我在以下页面上找到了上述示例: http://ec2-54-66-129-240.ap-southeast-2.compute.amazonaws.com/httrack/docs/cloud.google.com/datastore/docs/concepts/gql.html

它声明它是一个有效的 node.js 示例,但在运行查询时出现以下错误:

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

我正在使用最新版本的谷歌云节点:

"google-cloud": "^0.38.3",

有人用 gcloud 和 node 正确执行 GQL 查询吗?任何帮助将不胜感激。

【问题讨论】:

    标签: node.js google-cloud-datastore gcloud-node


    【解决方案1】:

    这显然是 Datastore 文档的缓存版本。那些 Node.js sn-ps 正在使用一个名为 googleapis 的不同库:https://github.com/google/google-api-nodejs-client

    另一个库 gcloud-node 目前不支持 GQL。

    【讨论】:

    • 我们仍然遇到同样的错误。对该 npm 模块所做的任何修复。
    猜你喜欢
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-01
    • 2015-11-01
    • 1970-01-01
    • 2018-01-22
    • 1970-01-01
    相关资源
    最近更新 更多