当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript paginator.paginator类代码示例

本文整理汇总了TypeScript中@google-cloud/paginator.paginator的典型用法代码示例。如果您正苦于以下问题:TypeScript paginator类的具体用法?TypeScript paginator怎么用?TypeScript paginator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了paginator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor


//.........这里部分代码省略.........
       * const BigQuery = require('@google-cloud/bigquery');
       * const bigquery = new BigQuery();
       *
       * const job = bigquery.job('id');
       * job.getMetadata((err, metadata, apiResponse) => {});
       *
       * //-
       * // If the callback is omitted, we'll return a Promise.
       * //-
       * job.getMetadata().then((data) => {
       *   const metadata = data[0];
       *   const apiResponse = data[1];
       * });
       */
      getMetadata: {
        reqOpts: {
          qs: {location},
        },
      },

      /**
       * Set the metadata for this job. This can be useful for updating job
       * labels.
       *
       * @see [Jobs: patch API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/v2/jobs/patch}
       *
       * @method Job#setMetadata
       * @param {object} metadata Metadata to save on the Job.
       * @param {function} [callback] The callback function.
       * @param {?error} callback.err An error returned while making this
       *     request.
       * @param {object} callback.apiResponse The full API response.
       * @returns {Promise}
       *
       * @example
       * const BigQuery = require('@google-cloud/bigquery');
       * const bigquery = new BigQuery();
       *
       * const metadata = {
       *   configuration: {
       *     labels: {
       *       foo: 'bar'
       *     }
       *   }
       * };
       *
       * const job = bigquery.job('job-id');
       *
       * job.setMetadata(metadata, (err, apiResponse) => {});
       *
       * //-
       * // If the callback is omitted, we'll return a Promise.
       * //-
       * job.setMetadata(metadata).then((data) => {
       *   const apiResponse = data[0];
       * });
       */
      setMetadata: true,
    };

    super({
      parent: bigQuery,
      baseUrl: '/jobs',
      id: id,
      methods: methods,
      requestModule: request,
    } as any);

    this.bigQuery = bigQuery;

    if (options && options.location) {
      this.location = options.location;
    }

    /**
    * Get the results of a job as a readable object stream.
    *
    * @param {object} options Configuration object. See
    *     {@link Job#getQueryResults} for a complete list of options.
    * @return {stream}
    *
    * @example
    * const through2 = require('through2');
    * const fs = require('fs');
    * const BigQuery = require('@google-cloud/bigquery');
    * const bigquery = new BigQuery();
    *
    * const job = bigquery.job('job-id');
    *
    * job.getQueryResultsStream()
    *   .pipe(through2.obj(function (row, enc, next) {
    *     this.push(JSON.stringify(row) + '\n');
    *     next();
    *   }))
    *   .pipe(fs.createWriteStream('./test/testdata/testfile.json'));
    */
    this.getQueryResultsStream = paginator.streamify(
      'getQueryResultsAsStream_'
    );
  }
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:101,代码来源:job.ts

示例2: callback

      if ((metadata as any).status.state !== 'DONE') {
        callback();
        return;
      }

      callback(null, metadata);
    });
  };
}

/*! Developer Documentation
 *
 * These methods can be auto-paginated.
 */
paginator.extend(Job, ['getQueryResults']);

/*! Developer Documentation
 *
 * All async methods (except for streams) will return a Promise in the event
 * that a callback is omitted.
 */
promisifyAll(Job);

/**
 * Reference to the {@link Job} class.
 * @name module:@google-cloud/bigquery.Job
 * @see Job
 */
export {Job};
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:29,代码来源:job.ts

示例3: extend

    options = extend(
      {
        location: this.location,
      },
      options
    );

    return new Table(this, id, options);
  };
}

/*! Developer Documentation
 *
 * These methods can be auto-paginated.
 */
paginator.extend(Dataset, ['getTables']);

/*! Developer Documentation
 *
 * All async methods (except for streams) will return a Promise in the event
 * that a callback is omitted.
 */
promisifyAll(Dataset, {
  exclude: ['table'],
});

/**
 * Reference to the {@link Dataset} class.
 * @name module:@google-cloud/bigquery.Dataset
 * @see Dataset
 */
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:31,代码来源:dataset.ts

示例4: constructor


//.........这里部分代码省略.........
      /**
       * Sets the metadata of the Dataset object.
       *
       * @see [Datasets: patch API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/v2/datasets/patch}
       *
       * @method Dataset#setMetadata
       * @param {object} metadata Metadata to save on the Dataset.
       * @param {function} [callback] The callback function.
       * @param {?error} callback.err An error returned while making this
       *     request.
       * @param {object} callback.apiResponse The full API response.
       * @returns {Promise}
       *
       * @example
       * const BigQuery = require('@google-cloud/bigquery');
       * const bigquery = new BigQuery();
       * const dataset = bigquery.dataset('institutions');
       *
       * const metadata = {
       *   description: 'Info for every institution in the 2013 IPEDS universe'
       * };
       *
       * dataset.setMetadata(metadata, (err, apiResponse) => {});
       *
       * //-
       * // If the callback is omitted, we'll return a Promise.
       * //-
       * dataset.setMetadata(metadata).then((data) => {
       *   const apiResponse = data[0];
       * });
       */
      setMetadata: true,
    };

    super({
      parent: bigQuery,
      baseUrl: '/datasets',
      id: id,
      methods: methods,
      requestModule: request,
      createMethod: (id, options, callback) => {
        if (is.fn(options)) {
          callback = options;
          options = {};
        }
        options = extend({}, options, {location: this.location});
        return bigQuery.createDataset(id, options, callback);
      },
    });

    if (options && options.location) {
      this.location = options.location;
    }

    this.bigQuery = bigQuery;

    // Catch all for read-modify-write cycle
    // https://cloud.google.com/bigquery/docs/api-performance#read-patch-write
    this.interceptors.push({
      request: function(reqOpts) {
        if (reqOpts.method === 'PATCH' && reqOpts.json.etag) {
          reqOpts.headers = reqOpts.headers || {};
          reqOpts.headers['If-Match'] = reqOpts.json.etag;
        }

        return reqOpts;
      },
    });

    /**
     * List all or some of the {module:bigquery/table} objects in your project as a
     * readable object stream.
     *
     * @param {object} [options] Configuration object. See
     *     {@link Dataset#getTables} for a complete list of options.
     * @return {stream}
     *
     * @example
     * const BigQuery = require('@google-cloud/bigquery');
     * const bigquery = new BigQuery();
     * const dataset = bigquery.dataset('institutions');
     *
     * dataset.getTablesStream()
     *   .on('error', console.error)
     *   .on('data', (table) => {})
     *   .on('end', () => {
     *     // All tables have been retrieved
     *   });
     *
     * //-
     * // If you anticipate many results, you can end a stream early to prevent
     * // unnecessary processing and API requests.
     * //-
     * dataset.getTablesStream()
     *   .on('data', function(table) {
     *     this.end();
     *   });
     */
    this.getTablesStream = paginator.streamify('getTables');
  }
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:101,代码来源:dataset.ts

示例5:

 *   })
 *   .on('end', function() {
 *     // All rows retrieved.
 *   });
 *
 * //-
 * // If you anticipate many results, you can end a stream early to prevent
 * // unnecessary processing and API requests.
 * //-
 * bigquery.createQueryStream(query)
 *   .on('data', function(row) {
 *     this.end();
 *   });
 */
BigQuery.prototype.createQueryStream = paginator.streamify(
  'queryAsStream_'
);

/**
 * Creates a job. Typically when creating a job you'll have a very specific task
 * in mind. For this we recommend one of the following methods:
 *
 * - {@link BigQuery#createQueryJob}
 * - {@link Table#createCopyJob}
 * - {@link Table#createCopyFromJob}
 * - {@link Table#createExtractJob}
 * - {@link Table#createLoadJob}
 *
 * However in the event you need a finer level of control over the job creation,
 * you can use this method to pass in a raw [Job resource](https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs)
 * object.
开发者ID:brgmn,项目名称:nodejs-bigquery,代码行数:31,代码来源:index.ts


注:本文中的@google-cloud/paginator.paginator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。