Skip to content

Latest commit

 

History

History

samples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Google Cloud Platform logo

Open in Cloud Shell

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.

Table of Contents

Before you begin

Before running the samples, make sure you've followed the steps outlined in Using the client library.

cd samples

npm install

cd ..

Samples

Add and drop new database role

View the source code.

Open in Cloud Shell

Usage:

node add-and-drop-new-database-role.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Backups-cancel

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-cancel.js


Copies a source backup

View the source code.

Open in Cloud Shell

Usage:

node spannerCopyBackup <INSTANCE_ID> <COPY_BACKUP_ID> <SOURCE_BACKUP_ID> <PROJECT_ID>


Backups-create-with-encryption-key

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-create-with-encryption-key.js


Backups-create

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-create.js


Backups-delete

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-delete.js


Backups-get-database-operations

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-get-database-operations.js


Backups-get-operations

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-get-operations.js


Backups-get

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-get.js


Backups-restore-with-encryption-key

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-restore-with-encryption-key.js


Backups-restore

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-restore.js


Backups-update

View the source code.

Open in Cloud Shell

Usage:

node samples/backups-update.js


Backups

View the source code.

Open in Cloud Shell

Usage:

node samples/backups.js


Batch Write

View the source code.

Open in Cloud Shell

Usage:

node batch-write.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Batch

View the source code.

Open in Cloud Shell

Usage:

node samples/batch.js


CRUD

View the source code.

Open in Cloud Shell

Usage:

node samples/crud.js


Creates a new database with a specific default leader

View the source code.

Open in Cloud Shell

Usage:

node database-create-with-default-leader.js <INSTANCE_ID> <DATABASE_ID> <DEFAULT_LEADER> <PROJECT_ID>


Database-create-with-encryption-key

View the source code.

Open in Cloud Shell

Usage:

node samples/database-create-with-encryption-key.js


Database-create-with-version-retention-period

View the source code.

Open in Cloud Shell

Usage:

node samples/database-create-with-version-retention-period.js


Gets the schema definition of an existing database

View the source code.

Open in Cloud Shell

Usage:

node database-get-ddl.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Gets the default leader option of an existing database

View the source code.

Open in Cloud Shell

Usage:

node database-get-default-leader.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Updates the default leader of an existing database

View the source code.

Open in Cloud Shell

Usage:

node database-update-default-leader.js <INSTANCE_ID> <DATABASE_ID> <DEFAULT_LEADER> <PROJECT_ID>


Updates a Cloud Spanner Database.

View the source code.

Open in Cloud Shell

Usage:

node database-update.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Datatypes

View the source code.

Open in Cloud Shell

Usage:

node samples/datatypes.js


Runs an execute sql request with directed read options

View the source code.

Open in Cloud Shell

Usage:

node directed-reads.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Delete using DML returning.

View the source code.

Open in Cloud Shell

Usage:

node dml-returning-delete.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Insert using DML returning.

View the source code.

Open in Cloud Shell

Usage:

node dml-returning-insert.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Update using DML returning.

View the source code.

Open in Cloud Shell

Usage:

node dml-returning-update.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


DML

View the source code.

Open in Cloud Shell

Usage:

node samples/dml.js


Enable fine grained access control

View the source code.

Open in Cloud Shell

Usage:

node enable-fine-grained-access.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Get-commit-stats

View the source code.

Open in Cloud Shell

Usage:

node samples/get-commit-stats.js


List database roles

View the source code.

Open in Cloud Shell

Usage:

node get-database-roles.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Gets the instance config metadata for the configuration nam6

View the source code.

Open in Cloud Shell

Usage:

node get-instance-config.js <PROJECT_ID>


Creates a new value-storing index

View the source code.

Open in Cloud Shell

Usage:

node createStoringIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Creates a new index

View the source code.

Open in Cloud Shell

Usage:

node createIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Executes a read-only SQL query using an existing index.

View the source code.

Open in Cloud Shell

Usage:

node queryDataWithIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID> <START_TITLE> <END_TITLE>


Reads data using an existing storing index.

View the source code.

Open in Cloud Shell

Usage:

node readDataWithStoringIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Read data using an existing index.

View the source code.

Open in Cloud Shell

Usage:

node readDataWithIndex <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Indexing

View the source code.

Open in Cloud Shell

Usage:

node samples/indexing.js


Creates a user-managed instance configuration.

View the source code.

Open in Cloud Shell

Usage:

node instance-config-create <INSTANCE_CONFIG_ID> <BASE_INSTANCE_CONFIG_ID> <PROJECT_ID>


Deletes a user-managed instance configuration.

View the source code.

Open in Cloud Shell

Usage:

node instance-config-delete <INSTANCE_CONFIG_ID> <PROJECT_ID>


Lists the instance configuration operations.

View the source code.

Open in Cloud Shell

Usage:

node instance-config-get-operations <PROJECT_ID>


Updates a user-managed instance configuration.

View the source code.

Open in Cloud Shell

Usage:

node instance-config-update <INSTANCE_CONFIG_ID> <PROJECT_ID>


Creates a new instance partition

View the source code.

Open in Cloud Shell

Usage:

node instance-partition-create.js <INSTANCE_ID> <INSTANCE_PARTITION_ID> <PROJECT_ID>


Creates a instance with autoscaling config.

View the source code.

Open in Cloud Shell

Usage:

node instance-with-autoscaling-config.js <INSTANCE_ID> <PROJECT_ID>


Instance-with-processing-units

View the source code.

Open in Cloud Shell

Usage:

node samples/instance-with-processing-units.js


Instance

View the source code.

Open in Cloud Shell

Usage:

node samples/instance.js


Json-add-column

View the source code.

Open in Cloud Shell

Usage:

node samples/json-add-column.js


Json-query-parameter

View the source code.

Open in Cloud Shell

Usage:

node samples/json-query-parameter.js


Json-update-data

View the source code.

Open in Cloud Shell

Usage:

node samples/json-update-data.js


Lists all databases on the selected instance

View the source code.

Open in Cloud Shell

Usage:

node list-databases.js <INSTANCE_ID> <PROJECT_ID>


Lists all the available instance configs for the selected project.

View the source code.

Open in Cloud Shell

Usage:

node list-instance-configs.js <PROJECT_ID>


Executes request with max commit delay

View the source code.

Open in Cloud Shell

Usage:

node max-commit-delay.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Numeric-add-column

View the source code.

Open in Cloud Shell

Usage:

node samples/numeric-add-column.js


Numeric-query-parameter

View the source code.

Open in Cloud Shell

Usage:

node samples/numeric-query-parameter.js


Numeric-update-data

View the source code.

Open in Cloud Shell

Usage:

node samples/numeric-update-data.js


Adds a column to an existing table in a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-add-column.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Showcase the rules for case-sensitivity and case folding for a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-case-sensitivity.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Creates a PostgreSQL Database.

View the source code.

Open in Cloud Shell

Usage:

node pg-database-create.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Use cast operator to cast from one data type to another in a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-datatypes-casting.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Execute a batch of DML statements on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-dml-batch.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Updates data in a table in a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-dml-getting-started-update.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Execute a Partitioned DML on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-dml-partitioned.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Delete using DML returning on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-dml-returning-delete.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Insert using DML returning on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-dml-returning-insert.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Update using DML returning on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-dml-returning-update.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Execute a DML statement with parameters on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-dml-with-parameter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Calls a server side function on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-functions.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Creates a new storing index in a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-index-create-storing.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Created interleaved table hierarchy using PostgreSQL dialect.

View the source code.

Open in Cloud Shell

Usage:

node pg-interleaving.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Showcase how add a jsonb column in a PostgreSQL table.

View the source code.

Open in Cloud Shell

Usage:

node pg-jsonb-add-column.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Showcase how query data to a jsonb column in a PostgreSQL table.

View the source code.

Open in Cloud Shell

Usage:

node pg-jsonb-query-parameter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Showcase how update data to a jsonb column in a PostgreSQL table.

View the source code.

Open in Cloud Shell

Usage:

node pg-jsonb-update-data.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Showcase how to work with the PostgreSQL NUMERIC/DECIMAL data type on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node ppg-numeric-data-type.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Showcases how a Spanner PostgreSQL database orders null values in a query.

View the source code.

Open in Cloud Shell

Usage:

node pg-ordering-nulls.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Execute a query with parameters on a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-query-parameter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Query the information schema metadata in a Spanner PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-schema-information.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Alters a sequence in a PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-sequence-alter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Creates sequence in PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-sequence-create.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Drops a sequence in PostgreSQL database.

View the source code.

Open in Cloud Shell

Usage:

node pg-sequence-drop.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Proto-query-data

View the source code.

Open in Cloud Shell

Usage:

node samples/proto-query-data.js


Creates a new database with a proto column and enum

View the source code.

Open in Cloud Shell

Usage:

node proto-type-add-column.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Proto-update-data-dml

View the source code.

Open in Cloud Shell

Usage:

node samples/proto-update-data-dml.js


Proto-update-data

View the source code.

Open in Cloud Shell

Usage:

node samples/proto-update-data.js


Queryoptions

View the source code.

Open in Cloud Shell

Usage:

node samples/queryoptions.js


Quickstart

View the source code.

Open in Cloud Shell

Usage:

node samples/quickstart.js


Read data with database role

View the source code.

Open in Cloud Shell

Usage:

node read-data-with-database-role.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Sets a request tag for a single query

View the source code.

Open in Cloud Shell

Usage:

node request-tag.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Run Batch update with RPC priority

View the source code.

Open in Cloud Shell

Usage:

node rpc-priority-batch-dml.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Run partitioned update with RPC priority

View the source code.

Open in Cloud Shell

Usage:

node rpc-priority-partitioned-dml.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Create partitions with RPC priority

View the source code.

Open in Cloud Shell

Usage:

node rpc-priority-query-partitions.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Read data with RPC Priority

View the source code.

Open in Cloud Shell

Usage:

node rpc-priority-read.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Query data with RPC Priority

View the source code.

Open in Cloud Shell

Usage:

node rpc-priority-run.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Run transaction with RPC priority

View the source code.

Open in Cloud Shell

Usage:

node rpc-priority-transaction.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Schema

View the source code.

Open in Cloud Shell

Usage:

node samples/schema.js


Alters a sequence in a GoogleSQL database.

View the source code.

Open in Cloud Shell

Usage:

node sequence-alter.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Creates sequence in GoogleSQL database.

View the source code.

Open in Cloud Shell

Usage:

node sequence-create.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Drops a sequence in GoogleSQL database.

View the source code.

Open in Cloud Shell

Usage:

node sequence-drop.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Struct

View the source code.

Open in Cloud Shell

Usage:

node samples/struct.js


Alters a table with foreign key delete cascade action

View the source code.

Open in Cloud Shell

Usage:

node table-alter-with-foreign-key-delete-cascade.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Creates a table with foreign key delete cascade action

View the source code.

Open in Cloud Shell

Usage:

node table-create-with-foreign-key-delete-cascade.js.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Drops a foreign key constraint with delete cascade action

View the source code.

Open in Cloud Shell

Usage:

node table-drop-foreign-key-constraint-delete-cascade.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Timestamp

View the source code.

Open in Cloud Shell

Usage:

node samples/timestamp.js


Executes a read/write transaction with transaction and request tags

View the source code.

Open in Cloud Shell

Usage:

node transaction-tag.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>


Transaction

View the source code.

Open in Cloud Shell

Usage:

node samples/transaction.js