Skip to content
Node.js client for Google Cloud Spanner: the world’s first fully managed relational database service to offer both strong consistency and horizontal scalability.
Branch: master
Clone or download
bcoe and JustinBeckwith fix(docs): link to reference docs section on googleapis.dev (#654)
* fix(docs): reference docs should link to section of googleapis.dev with API reference

* fix(docs): make anchors work in jsdoc
Latest commit 2379dc2 Jun 25, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github chore: move CONTRIBUTING.md to root (#514) Feb 7, 2019
.kokoro build: switch to GitHub magic proxy, for release-please (#648) Jun 18, 2019
benchmark tests: correctly sort latencies (#564) Mar 13, 2019
proto refactor(types): enable noImplicitAny in session-pool.ts (#508) Feb 8, 2019
protos/google feat(transaction): batch dml (#550) Mar 7, 2019
samples docs(samples): fix code snippets that transfer money between albums (#… Jun 7, 2019
scripts refactor: removed async from dependency list (#449) Dec 14, 2018
src fix: update retry config (#650) Jun 20, 2019
system-test refactor(system-test): implement logic to clean up old instances (#630) Jun 8, 2019
test fix(deps): update dependency p-queue to v6.0.2 (#643) Jun 7, 2019
.eslintignore chore: update nyc and eslint configs (#477) Dec 11, 2018
.eslintrc.yml chore: update auto-generated config (#362) Oct 5, 2018
.gitignore feat: add .repo-metadata.json and move to new README template (#636) Jun 1, 2019
.jsdoc.js fix(docs): link to reference docs section on googleapis.dev (#654) Jun 25, 2019
.nycrc build: ignore proto files in test coverage (#628) May 28, 2019
.prettierignore Repo Migration (#10) Oct 26, 2017
.prettierrc Repo Migration (#10) Oct 26, 2017
.readme-partials.yml feat: add .repo-metadata.json and move to new README template (#636) Jun 1, 2019
.repo-metadata.json fix(docs): move to new client docs URL (#647) Jun 13, 2019
CHANGELOG.md Release @google-cloud/spanner v3.1.0 (#552) Mar 7, 2019
CODE_OF_CONDUCT.md Repo Migration (#10) Oct 26, 2017
CONTRIBUTING.md docs: update links in contrib guide (#525) Feb 14, 2019
LICENSE chore: update license file (#464) Dec 4, 2018
README.md fix(docs): link to reference docs section on googleapis.dev (#654) Jun 25, 2019
codecov.yaml Update CI config (#354) Oct 2, 2018
package.json chore(deps): update dependency @types/async to v3 (#641) Jun 7, 2019
renovate.json chore: ignore package-lock.json (#286) Aug 7, 2018
synth.metadata fix: update retry config (#650) Jun 20, 2019
synth.py build: check broken links in generated docs (#491) Jan 14, 2019
tsconfig.json chore: add spanner_grpc_config.json and enable grpc-gcp support for s… Feb 15, 2019
tslint.json refactor(typescript): perform initial TypeScript conversion (#384) Oct 23, 2018

README.md

Google Cloud Platform logo

Cloud Spanner: Node.js Client

release level npm version codecov

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 more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Cloud Spanner API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/spanner

Using the client library

  // Imports the Google Cloud client library
  const {Spanner} = require('@google-cloud/spanner');

  // Creates a client
  const spanner = new Spanner({projectId});

  // Gets a reference to a Cloud Spanner instance and database
  const instance = spanner.instance(instanceId);
  const database = instance.database(databaseId);

  // The query to execute
  const query = {
    sql: 'SELECT 1',
  };

  // Execute a simple SQL statement
  const [rows] = await database.run(query);
  console.log(`Query: ${rows.length} found.`);
  rows.forEach(row => console.log(row));

Samples

Samples are in the samples/ directory. The samples' README.md has instructions for running the samples.

Sample Source Code Try it
Batch source code Open in Cloud Shell
CRUD source code Open in Cloud Shell
DML source code Open in Cloud Shell
Indexing source code Open in Cloud Shell
Quickstart source code Open in Cloud Shell
Schema source code Open in Cloud Shell
Struct source code Open in Cloud Shell
Timestamp source code Open in Cloud Shell
Transaction source code Open in Cloud Shell

The Cloud Spanner Node.js Client API Reference documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

You can’t perform that action at this time.