@@ -168,9 +168,14 @@ BigQuery.prototype.dataset = function(id) {
168168 * @param {function } callback - The callback function.
169169 *
170170 * @example
171- * bigquery.getDatasets(function(err, datasets, nextQuery, apiResponse) {
172- * // If `nextQuery` is non-null, there are more results to fetch.
173- * });
171+ * var callback = function(err, datasets, nextQuery, apiResponse) {
172+ * if (nextQuery) {
173+ * // More results exist.
174+ * bigquery.getDatasets(nextQuery, callback);
175+ * }
176+ * };
177+ *
178+ * bigquery.getDatasets(callback);
174179 *
175180 * //-
176181 * // Get the datasets from your project as a readable object stream.
@@ -183,6 +188,15 @@ BigQuery.prototype.dataset = function(id) {
183188 * .on('end', function() {
184189 * // All datasets retrieved.
185190 * });
191+ *
192+ * //-
193+ * // If you anticipate many results, you can end a stream early to prevent
194+ * // unnecessary processing and API requests.
195+ * //-
196+ * bigquery.getDatasets()
197+ * .on('data', function(dataset) {
198+ * this.end();
199+ * });
186200 */
187201BigQuery . prototype . getDatasets = function ( query , callback ) {
188202 var that = this ;
@@ -250,6 +264,15 @@ BigQuery.prototype.getDatasets = function(query, callback) {
250264 * .on('end', function() {
251265 * // All jobs retrieved.
252266 * });
267+ *
268+ * //-
269+ * // If you anticipate many results, you can end a stream early to prevent
270+ * // unnecessary processing and API requests.
271+ * //-
272+ * bigquery.getJobs()
273+ * .on('data', function(job) {
274+ * this.end();
275+ * });
253276 */
254277BigQuery . prototype . getJobs = function ( options , callback ) {
255278 var that = this ;
@@ -330,14 +353,15 @@ BigQuery.prototype.job = function(id) {
330353 * //-
331354 * // You can run a query against your data in a serial manner.
332355 * //-
333- * bigquery.query(query, function(err, rows, nextQuery, apiResponse) {
356+ * var callback = function(err, rows, nextQuery, apiResponse) {
334357 * // Handle results here.
358+ *
335359 * if (nextQuery) {
336- * bigquery.query(nextQuery, function(err, rows, nextQuery, apiResponse) {
337- * // Handle more results here.
338- * });
360+ * bigquery.query(nextQuery, callback);
339361 * }
340- * });
362+ * };
363+ *
364+ * bigquery.query(query, callback);
341365 *
342366 * //-
343367 * // You can also use the `query` method as a readable object stream by
0 commit comments