Skip to content

Latest commit

 

History

History
 
 

README.md

Google Cloud Platform logo

Cloud Spanner Node.js Samples

Cloud Spanner is a managed, mission-critical, globally consistent and scalable relational database service. Cloud Spanner solves the need for a horizontally-scaling database with consistent global transaction and SQL semantics.

Table of Contents

Setup

  1. Read Prerequisites and How to run a sample first.

  2. Install dependencies:

     npm install
    

Samples

Getting started with Google Cloud Spanner API

View the Spanner documentation or the samples.

Run the samples:

node schema.js --help
Commands:
  createDatabase <instanceName> <databaseName>  Creates an example database with two tables in a Cloud Spanner instance.
  addColumn <instanceName> <databaseName>       Adds an example MarketingBudget column to an example Cloud Spanner
                                                table.
  queryNewColumn <instanceName> <databaseName>  Executes a read-only SQL query against an example Cloud Spanner table
                                                with an additional column (MarketingBudget) added by addColumn.

Options:
  --help  Show help                                                                                            [boolean]

Examples:
  node schema.js createDatabase "my-instance" "my-database"
  node schema.js addColumn "my-instance" "my-database"
  node schema.js queryNewColumn "my-instance" "my-database"

For more information, see https://cloud.google.com/spanner/docs
node crud.js --help
Commands:
  update <instanceName> <databaseName>  Modifies existing rows of data in an example Cloud Spanner table.
  query <instanceName> <databaseName>   Executes a read-only SQL query against an example Cloud Spanner table.
  insert <instanceName> <databaseName>  Inserts new rows of data into an example Cloud Spanner table.
  read <instanceName> <databaseName>    Reads data in an example Cloud Spanner table.

Options:
  --help  Show help                                                                                            [boolean]

Examples:
  node crud.js update "my-instance" "my-database"
  node crud.js query "my-instance" "my-database"
  node crud.js insert "my-instance" "my-database"
  node crud.js read "my-instance" "my-database"

For more information, see https://cloud.google.com/spanner/docs
node indexing.js --help
Commands:
  createIndex <instanceName> <databaseName>         Creates a new index in an example Cloud Spanner table.
  createStoringIndex <instanceName> <databaseName>  Creates a new value-storing index in an example Cloud Spanner table.
  queryIndex <instanceName> <databaseName>          Executes a read-only SQL query against an example Cloud Spanner
                                                    table using an existing index.
  readIndex <instanceName> <databaseName>           Reads data from an example Cloud Spanner table using an existing
                                                    index.
  readStoringIndex <instanceName> <databaseName>    Reads data from an example Cloud Spanner table using an existing
                                                    storing index.

Options:
  --help  Show help                                                                                            [boolean]

Examples:
  node indexing.js createIndex "my-instance" "my-database"
  node indexing.js createStoringIndex "my-instance" "my-database"
  node indexing.js queryIndex "my-instance" "my-database"
  node indexing.js readIndex "my-instance" "my-database"
  node indexing.js readStoringIndex "my-instance" "my-database"

For more information, see https://cloud.google.com/spanner/docs
node transaction.js --help
Commands:
  readOnly <instanceName> <databaseName>   Execute a read-only transaction on an example Cloud Spanner table.
  readWrite <instanceName> <databaseName>  Execute a read-write transaction on an example Cloud Spanner table.

Options:
  --help  Show help                                                                                            [boolean]

Examples:
  node transaction.js readOnly "my-instance" "my-database"
  node transaction.js readWrite "my-instance" "my-database"

For more information, see https://cloud.google.com/spanner/docs

For more information, see the docs.