Skip to content

Commit acdb279

Browse files
fix docs + allow read consistency on query.run
1 parent 058b5d8 commit acdb279

3 files changed

Lines changed: 21 additions & 26 deletions

File tree

lib/datastore/query.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,18 +307,15 @@ Query.prototype.offset = function(n) {
307307
/**
308308
* Run the query.
309309
*
310+
* @param {object=} options - Optional configuration.
311+
* @param {string} options.consistency - Specify either `strong` or `eventual`.
312+
* If not specified, default values are chosen by Datastore for the
313+
* operation. Learn more about strong and eventual consistency
314+
* [here](https://cloud.google.com/datastore/docs/articles/balancing-strong-and-eventual-consistency-with-google-cloud-datastore).
310315
* @param {function=} callback - The callback function. If omitted, a readable
311316
* stream instance is returned.
312317
* @param {?error} callback.err - An error returned while making this request
313-
* (may be null).
314-
* @param {array} callback.entities - The list of entities returned by this
315-
* query. Note that this is a single page of entities, not necessarily
316-
* all of the entities.
317-
* @param {?module:datastore/query} callback.nextQuery - If present, run another
318-
* query with this object to check for more results.
319-
* @param {object} callback.apiResponse - The full API response.
320-
* @param {?error} callback.err - An error returned while making this request
321-
* @param {module:datastore/entity[]} callback.entities - A list of Entities
318+
* @param {object[]} callback.entities - A list of entities.
322319
* @param {?object} callback.nextQuery - If present, query with this object to
323320
* check for more results.
324321
* @param {object} callback.apiResponse - The full API response.
@@ -372,8 +369,11 @@ Query.prototype.offset = function(n) {
372369
* // entities[].data = Empty object
373370
* });
374371
*/
375-
Query.prototype.run = function(callback) {
376-
return this.scope.runQuery(this, callback);
372+
Query.prototype.run = function() {
373+
var query = this;
374+
var args = [query].concat([].slice.call(arguments));
375+
376+
return this.scope.runQuery.apply(this.scope, args);
377377
};
378378

379379
module.exports = Query;

lib/datastore/request.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,7 @@ DatastoreRequest.prototype.insert = function(entities, callback) {
388388
* @param {function=} callback - The callback function. If omitted, a readable
389389
* stream instance is returned.
390390
* @param {?error} callback.err - An error returned while making this request
391-
* (may be null).
392-
* @param {array} callback.entities - The list of entities returned by this
393-
* query. Note that this is a single page of entities, not necessarily
394-
* all of the entities.
395-
* @param {?module:datastore/query} callback.nextQuery - If present, run another
396-
* query with this object to check for more results.
397-
* @param {object} callback.apiResponse - The full API response.
398-
* @param {?error} callback.err - An error returned while making this request
399-
* @param {module:datastore/entity[]} callback.entities - A list of Entities
391+
* @param {object[]} callback.entities - A list of entities.
400392
* @param {?object} callback.nextQuery - If present, query with this object to
401393
* check for more results.
402394
* @param {object} callback.apiResponse - The full API response.

test/datastore/query.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
var assert = require('assert');
2020

2121
var Query = require('../../lib/datastore/query.js');
22-
var util = require('../../lib/common/util.js');
2322

2423
describe('Query', function() {
2524
var SCOPE = {};
@@ -321,16 +320,20 @@ describe('Query', function() {
321320

322321
describe('run', function() {
323322
it('should call the parent instance runQuery correctly', function() {
323+
var args = [0, 1, 2];
324324
var runQueryReturnValue = {};
325-
var callback = util.noop;
326325

327-
query.scope.runQuery = function(query_, callback_) {
328-
assert.strictEqual(query_, query);
329-
assert.strictEqual(callback_, callback);
326+
query.scope.runQuery = function() {
327+
assert.strictEqual(this, query.scope);
328+
assert.strictEqual(arguments[0], query);
329+
assert.strictEqual(arguments[1], args[0]);
330+
assert.strictEqual(arguments[2], args[1]);
331+
assert.strictEqual(arguments[3], args[2]);
330332
return runQueryReturnValue;
331333
};
332334

333-
assert.strictEqual(query.run(callback), runQueryReturnValue);
335+
var results = query.run.apply(query, args);
336+
assert.strictEqual(results, runQueryReturnValue);
334337
});
335338
});
336339
});

0 commit comments

Comments
 (0)