result.batch.entityResults给出undefines错误

时间:2016-02-13 22:19:53

标签: node.js google-app-engine google-cloud-datastore

我正在谷歌应用引擎云数据存储区上运行nodejs应用。安装了gcloud模块但是当我输入result.batch.entityResults时,它在查询后给出了一个未定义的错误,它给出了一个未定义的错误。

function signup(minHeight,maxHeight,callback) {

  var heightRangeQuery = {
    kinds: [{ name: 'Person' }],
    filter: {
      // Combine multiple filters by using a compositeFilter.
      compositeFilter: {
        operator: 'AND',
        filters: [{
          propertyFilter: {
            property: { name: 'height' },
            operator: 'GREATER_THAN_OR_EQUAL',
            value: { integerValue: minHeight }
          }
        }, {
          propertyFilter: {
            property: { name: 'height' },
            operator: 'LESS_THAN_OR_EQUAL',
            value: { integerValue: maxHeight }
          }
        }]
      },
    }
  };

  datastore.runQuery({
    query: heightRangeQuery
  }).execute(function(err, result) {
    // Iterate over the results.
    if (!err && result.batch.entityResults) {
      result.batch.entityResults.forEach(function(er) {
        var entity = er.entity;
        console.log(entity.properties.firstName.stringValue, ' ',
            entity.properties.lastName.stringValue, ', ',
            entity.properties.height.integerValue, ' inches tall');
      });
      if (result.batch.moreResults == 'NOT_FINISHED') {
        var endCursor = result.batch.endCursor;
        heightRangeQuery.startCursor = endCursor;
        // Reissue the query to get more results...
      }
    }
    callback(err);
  });
}

0 个答案:

没有答案