From 5e5ac9fc5eaecb32aea116ba6a101d82672131c9 Mon Sep 17 00:00:00 2001 From: Philip Irri Date: Wed, 13 Sep 2017 11:30:49 +0900 Subject: [PATCH 1/2] Example with eventual read consistency in Node.js --- datastore/concepts.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/datastore/concepts.js b/datastore/concepts.js index 277b93e581..453457b6b7 100644 --- a/datastore/concepts.js +++ b/datastore/concepts.js @@ -1033,9 +1033,25 @@ class Query extends TestHelper { testEventualConsistentQuery (t) { t.plan(0); + const datastoreMock = datastore; + datastore = this.datastore; // [START eventual_consistent_query] - // Read consistency cannot be specified in google-cloud-node. + const ancestorKey = datastore.key(['TaskList', 'default']); + const query = datastore.createQuery('Task') + .hasAncestor(ancestorKey); + + query.run({ consistency: 'eventual' }); // [END eventual_consistent_query] + return query.run({ consistency: 'eventual' }) + .then((results) => { + datastore = datastoreMock; + const entities = results[0]; + return entities; + }) + .catch((err) => { + datastore = datastoreMock; + return Promise.reject(err); + }); } } From 64b28586e0f6400a324deb26357e98ef7c6e2b4d Mon Sep 17 00:00:00 2001 From: Jason Dobry Date: Tue, 19 Sep 2017 10:17:39 -0700 Subject: [PATCH 2/2] Couple updates. --- datastore/README.md | 3 ++- datastore/package.json | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/datastore/README.md b/datastore/README.md index d3475602db..f1cbd55934 100644 --- a/datastore/README.md +++ b/datastore/README.md @@ -47,7 +47,8 @@ Commands: delete Deletes a task. Options: - --help Show help [boolean] + --version Show version number [boolean] + --help Show help [boolean] Examples: node tasks.js new "Buy milk" Adds a task with description "Buy milk". diff --git a/datastore/package.json b/datastore/package.json index 42673c3698..ae79053edd 100644 --- a/datastore/package.json +++ b/datastore/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" }, "engines": { - "node": ">=4.3.2" + "node": ">=4" }, "scripts": { "lint": "samples lint", @@ -18,13 +18,13 @@ }, "dependencies": { "@google-cloud/datastore": "1.1.0", - "yargs": "8.0.2" + "yargs": "9.0.1" }, "devDependencies": { "@google-cloud/nodejs-repo-tools": "1.4.17", - "ava": "0.21.0", + "ava": "0.22.0", "proxyquire": "1.8.0", - "sinon": "3.2.0" + "sinon": "3.3.0" }, "cloud-repo-tools": { "requiresKeyFile": true,