Cloud Spanner is a fully managed, mission-critical, relational database service that offers transactional consistency at global scale, schemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication for high availability.
-
Read Prerequisites and How to run a sample first.
-
Install dependencies:
With npm:
npm install
With yarn:
yarn install
View the documentation or the source code.
Usage: 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
View the documentation or the source code.
Usage: 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
View the documentation or the source code.
Usage: 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
View the documentation or the source code.
Usage: 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
-
Set the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS environment variables.
-
Run the tests:
With npm:
npm test
With yarn:
yarn test