本文整理匯總了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_'
);
}
示例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};
示例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
*/
示例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');
}
示例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.