Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example with eventual read consistency in Node.js #480

Merged
merged 3 commits into from
Sep 19, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion datastore/concepts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}

Expand Down