New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/spanner

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/spanner

Cloud Spanner Client Library for Node.js

  • 4.6.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
105K
decreased by-5.51%
Maintainers
1
Weekly downloads
 
Created

What is @google-cloud/spanner?

@google-cloud/spanner is a Node.js client library for Google Cloud Spanner, a fully managed, scalable, globally distributed, and strongly consistent database service. This package allows developers to interact with Cloud Spanner databases, perform CRUD operations, execute SQL queries, and manage database schemas.

What are @google-cloud/spanner's main functionalities?

Connecting to a Spanner Instance

This code demonstrates how to connect to a Spanner instance using the @google-cloud/spanner package. You need to provide your Google Cloud project ID and the Spanner instance ID.

const {Spanner} = require('@google-cloud/spanner');
const spanner = new Spanner({
  projectId: 'your-project-id',
});
const instance = spanner.instance('your-instance-id');

Creating a Database

This code shows how to create a new database within a Spanner instance. The `create` method returns an operation that you can wait for to ensure the database is created successfully.

const database = instance.database('your-database-id');
const [operation] = await database.create();
await operation.promise();
console.log(`Database ${database.id} created.`);

Executing a SQL Query

This code demonstrates how to execute a SQL query on a Spanner database. The `run` method executes the query and returns the result rows.

const query = {
  sql: 'SELECT * FROM your-table',
};
const [rows] = await database.run(query);
rows.forEach(row => console.log(row.toJSON()));

Inserting Data

This code shows how to insert data into a table in a Spanner database. The `insert` method is used to add a new row to the specified table.

const table = database.table('your-table');
await table.insert({
  column1: 'value1',
  column2: 'value2',
});
console.log('Data inserted.');

Updating Data

This code demonstrates how to update existing data in a table. The `update` method is used to modify the values of specified columns.

await table.update({
  column1: 'new-value1',
  column2: 'new-value2',
});
console.log('Data updated.');

Other packages similar to @google-cloud/spanner

Keywords

FAQs

Package last updated on 30 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc