我正在尝试运行以下 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/概念/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 查询?任何帮助将不胜感激。