From 2c19dd1f55be9bf51c553e61137fe285b9eab862 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Mon, 17 Jul 2017 15:44:12 -0400 Subject: [PATCH] spanner: promote to beta (#2452) --- README.md | 163 +++++++++++++++++++------------------ packages/spanner/README.md | 17 ++-- 2 files changed, 91 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index f51eb4f616a..58f669ef4e6 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ This client supports the following Google Cloud Platform services at a [General This client supports the following Google Cloud Platform services at a [Beta](#versioning) quality level: * [Cloud Natural Language](#cloud-natural-language-beta) (Beta) +* [Cloud Spanner](#cloud-spanner-beta) (Beta) * [Cloud Vision](#cloud-vision-beta) (Beta) * [Google BigQuery](#google-bigquery-beta) (Beta) @@ -29,7 +30,6 @@ This client supports the following Google Cloud Platform services at an [Alpha]( * [Cloud DNS](#cloud-dns-alpha) (Alpha) * [Cloud Pub/Sub](#cloud-pubsub-alpha) (Alpha) * [Cloud Resource Manager](#cloud-resource-manager-alpha) (Alpha) -* [Cloud Spanner](#cloud-spanner-alpha) (Alpha) * [Cloud Speech](#cloud-speech-alpha) (Alpha) * [Google Compute Engine](#google-compute-engine-alpha) (Alpha) * [Google Prediction API](#google-prediction-api-alpha) (Alpha) @@ -530,6 +530,87 @@ document.annotate(function(err, annotation) { ``` +## Cloud Spanner (Beta) + +- [API Documentation][gcloud-spanner-docs] +- [Official Documentation][cloud-spanner-docs] + +#### Using the Cloud Spanner API module + +``` +$ npm install --save @google-cloud/spanner +``` + +```js +var spanner = require('@google-cloud/spanner'); +``` + +#### Preview + +```js +// Authenticating on a per-API-basis. You don't need to do this if you auth on a +// global basis (see Authentication section above). + +var spannerClient = spanner({ + projectId: 'grape-spaceship-123', + keyFilename: '/path/to/keyfile.json' +}); + +var instance = spannerClient.instance('my-instance'); +var database = instance.database('my-database'); + +// Create a table. +var schema = ` + CREATE TABLE Singers ( + SingerId INT64 NOT NULL, + FirstName STRING(1024), + LastName STRING(1024), + SingerInfo BYTES(MAX), + ) PRIMARY KEY(SingerId) +`; + +database.createTable(schema, function(err, table, operation) { + if (err) { + // Error handling omitted. + } + + operation + .on('error', function(err) {}) + .on('complete', function() { + // Table created successfully. + }); +}); + +// Insert data into the table. +var table = database.table('Singers'); + +table.insert({ + SingerId: 10, + FirstName: 'Eddie', + LastName: 'Wilson' +}, function(err) { + if (!err) { + // Row inserted successfully. + } +}); + +// Run a query as a readable object stream. +database.runStream('SELECT * FROM Singers') + .on('error', function(err) {}) + .on('data', function(row) { + // row.toJSON() = { + // SingerId: 10, + // FirstName: 'Eddie', + // LastName: 'Wilson' + // } + } + }) + .on('end', function() { + // All results retrieved. + }); +``` + + ## Cloud Vision (Beta) - [API Documentation][gcloud-vision-docs] @@ -891,86 +972,6 @@ project.getMetadata(function(err, metadata) { ``` -## Cloud Spanner (Alpha) - -- [API Documentation][gcloud-spanner-docs] -- [Official Documentation][cloud-spanner-docs] - -#### Using the Cloud Spanner API module - -``` -$ npm install --save @google-cloud/spanner -``` - -```js -var spanner = require('@google-cloud/spanner'); -``` - -#### Preview - -```js -// Authenticating on a per-API-basis. You don't need to do this if you auth on a -// global basis (see Authentication section above). - -var spannerClient = spanner({ - projectId: 'grape-spaceship-123', - keyFilename: '/path/to/keyfile.json' -}); - -var instance = spannerClient.instance('my-instance'); -var database = instance.database('my-database'); - -// Create a table. -var schema = - 'CREATE TABLE Singers (' + - ' SingerId INT64 NOT NULL,' + - ' FirstName STRING(1024),' + - ' LastName STRING(1024),' + - ' SingerInfo BYTES(MAX),' + - ') PRIMARY KEY(SingerId)'; - -database.createTable(schema, function(err, table, operation) { - if (err) { - // Error handling omitted. - } - - operation - .on('error', function(err) {}) - .on('complete', function() { - // Table created successfully. - }); -}); - -// Insert data into the table. -var table = database.table('Singers'); - -table.insert({ - SingerId: 10, - FirstName: 'Eddie', - LastName: 'Wilson' -}, function(err) { - if (!err) { - // Row inserted successfully. - } -}); - -// Run a query as a readable object stream. -database.runStream('SELECT * FROM Singers') - .on('error', function(err) {}) - .on('data', function(row) { - // row.toJSON() = { - // SingerId: 10, - // FirstName: 'Eddie', - // LastName: 'Wilson' - // } - } - }) - .on('end', function() { - // All results retrieved. - }); -``` - - ## Cloud Speech (Alpha) - [API Documentation][gcloud-speech-docs] diff --git a/packages/spanner/README.md b/packages/spanner/README.md index d99ce157f47..d8555dcefe4 100644 --- a/packages/spanner/README.md +++ b/packages/spanner/README.md @@ -1,4 +1,4 @@ -# @google-cloud/spanner ([Alpha][versioning]) +# @google-cloud/spanner ([Beta][versioning]) > Cloud Spanner Client Library for Node.js *Looking for more Google APIs than just Cloud Spanner? You might want to check out [`google-cloud`][google-cloud].* @@ -20,13 +20,14 @@ var instance = spanner.instance('my-instance'); var database = instance.database('my-database'); // Create a table. -var schema = - 'CREATE TABLE Singers (' + - ' SingerId INT64 NOT NULL,' + - ' FirstName STRING(1024),' + - ' LastName STRING(1024),' + - ' SingerInfo BYTES(MAX),' + - ') PRIMARY KEY(SingerId)'; +var schema = ` + CREATE TABLE Singers ( + SingerId INT64 NOT NULL, + FirstName STRING(1024), + LastName STRING(1024), + SingerInfo BYTES(MAX), + ) PRIMARY KEY(SingerId) +`; database.createTable(schema, function(err, table, operation) { if (err) {