diff --git a/samples/README.md b/samples/README.md index 1c0073a9b..75f28de94 100644 --- a/samples/README.md +++ b/samples/README.md @@ -1,3 +1,5 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `npm run generate-scaffolding`." Google Cloud Platform logo # Google Cloud Datastore: Node.js Samples @@ -29,29 +31,6 @@ View the [source code][tasks_0_code]. [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.js,samples/README.md) __Usage:__ `node tasks.js --help` - -``` -tasks.js - -Commands: - tasks.js new Adds a task with a description . - tasks.js done Marks the specified task as done. - tasks.js list Lists all tasks ordered by creation time. - tasks.js delete Deletes a task. - -Options: - --version Show version number [boolean] - --help Show help [boolean] - -Examples: - node tasks.js new "Buy milk" Adds a task with description "Buy milk". - node tasks.js done 12345 Marks task 12345 as Done. - node tasks.js list Lists all tasks ordered by creation time - node tasks.js delete 12345 Deletes task 12345. - -For more information, see https://cloud.google.com/datastore/docs -``` - [tasks_0_docs]: https://cloud.google.com/datastore/docs/datastore-api-tutorial [tasks_0_code]: tasks.js @@ -72,5 +51,5 @@ __Usage:__ `node error.js` [error_2_docs]: https://cloud.google.com/datastore/docs/concepts/errors [error_2_code]: error.js -[shell_img]: //gstatic.com/cloudssh/images/open-btn.png +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png [shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/README.md diff --git a/samples/concepts.js b/samples/concepts.js index d62737116..6f5ac3705 100644 --- a/samples/concepts.js +++ b/samples/concepts.js @@ -817,21 +817,6 @@ class Query extends TestHelper { return this.datastore.runQuery(query); } - testDistinctQuery(t) { - t.plan(0); - const datastore = this.datastore; - - // [START datastore_distinct_query] - const query = datastore - .createQuery('Task') - .groupBy(['category', 'priority']) - .order('category') - .order('priority'); - // [END datastore_distinct_query] - - return this.datastore.runQuery(query); - } - testDistinctOnQuery(t) { t.plan(0); const datastore = this.datastore; diff --git a/samples/error.js b/samples/error.js deleted file mode 100644 index bd20ea214..000000000 --- a/samples/error.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright 2017, Google, Inc. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const Datastore = require('@google-cloud/datastore'); - -// [START error] -function runQuery() { - // Creates a client - const datastore = new Datastore({}); - - const query = datastore.createQuery(['Company']).start('badrequest'); - - return datastore - .runQuery(query) - .then(results => { - const entities = results[0]; - console.log('Entities:'); - entities.forEach(entity => console.log(entity)); - return entities; - }) - .catch(err => { - console.log(err.errors); // [...] - console.log(err.code); // 3 (a gRPC error code) - console.log(err.message); // "Bad Request" - console.log(err.response); // {...} - - // Process error - - // For example, treat permission error like no entities were found - // eslint-disable-next-line no-constant-condition - if (/* some condition */ false) { - return []; - } - - // Forward the error to the caller - return Promise.reject(err); - }); -} -// [END error] - -exports.runQuery = runQuery; - -if (module === require.main) { - exports.runQuery(); -} diff --git a/samples/system-test/concepts.test.js b/samples/system-test/concepts.test.js index 9d606618f..a2a4aa12f 100644 --- a/samples/system-test/concepts.test.js +++ b/samples/system-test/concepts.test.js @@ -117,7 +117,6 @@ test.serial('performs a projection query', t => { }); }); test.serial(`performs a keys only query`, t => query.testKeysOnlyQuery(t)); -test.serial(`performs a distinct query`, t => query.testDistinctQuery(t)); test.serial(`performs a distinct on query`, t => query.testDistinctOnQuery(t)); test.serial(`performs an array value inequality query`, t => query.testArrayValueInequalityRange(t) diff --git a/samples/system-test/error.test.js b/samples/system-test/error.test.js deleted file mode 100644 index a584466b7..000000000 --- a/samples/system-test/error.test.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright 2017, Google, Inc. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const error = require('../error'); -const test = require(`ava`); -const tools = require(`@google-cloud/nodejs-repo-tools`); - -test.beforeEach(tools.stubConsole); -test.afterEach.always(tools.restoreConsole); - -test(`should have an error`, async t => { - const err = await t.throws(error.runQuery()); - t.truthy(err); - t.is(err.code, 3); -}); diff --git a/samples/tasks.js b/samples/tasks.js index 46113129b..71e8bf668 100644 --- a/samples/tasks.js +++ b/samples/tasks.js @@ -158,7 +158,6 @@ function deleteTask(taskId) { // [END datastore_delete_entity] require(`yargs`) // eslint-disable-line - .demand(1) .command( `new `, `Adds a task with a description .`, @@ -178,5 +177,4 @@ require(`yargs`) // eslint-disable-line .example(`node $0 delete 12345`, `Deletes task 12345.`) .wrap(120) .epilogue(`For more information, see https://cloud.google.com/datastore/docs`) - .help() - .strict().argv; + .help().argv;