Skip to content

v0.47.0

Choose a tag to compare

@stephenplusplus stephenplusplus released this 14 Feb 17:46

Update

$ npm install google-cloud@0.47.0

Hello, Cloud Spanner!

Cloud Spanner is a highly scalable, transactional, managed, NewSQL database service. Cloud Spanner solves the need for a horizontally-scaling database with consistent global transaction and SQL semantics. With Cloud Spanner you don't need to choose between consistency and horizontal scaling — you get both.

var spanner = require('google-cloud').spanner({
  projectId: 'grape-spaceship-123',
  keyFilename: '/path/to/keyfile.json'
});

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)';

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.
  });

Features

Fixes

  • Pub/Sub (#1925, #1931): Properly parse messages' publishTime property. (Thanks, @arbesfeld!)
  • Speech (#1894, #1915): Increase the request timeout to 190 seconds to allow recognition of longer input audio streams.