MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / updateUsingPartitionedDml

Function updateUsingPartitionedDml

spanner/dml.js:466–499  ·  view source on GitHub ↗
(instanceId, databaseId, projectId)

Source from the content-addressed store, hash-verified

464}
465
466async function updateUsingPartitionedDml(instanceId, databaseId, projectId) {
467 // [START spanner_dml_partitioned_update]
468 // Imports the Google Cloud client library
469 const {Spanner} = require('@google-cloud/spanner');
470
471 /**
472 * TODO(developer): Uncomment the following lines before running the sample.
473 */
474 // const projectId = 'my-project-id';
475 // const instanceId = 'my-instance';
476 // const databaseId = 'my-database';
477
478 // Creates a client
479 const spanner = new Spanner({
480 projectId: projectId,
481 });
482
483 // Gets a reference to a Cloud Spanner instance and database
484 const instance = spanner.instance(instanceId);
485 const database = instance.database(databaseId);
486
487 try {
488 const [rowCount] = await database.runPartitionedUpdate({
489 sql: 'UPDATE Albums SET MarketingBudget = 100000 WHERE SingerId > 1',
490 });
491 console.log(`Successfully updated ${rowCount} records.`);
492 } catch (err) {
493 console.error('ERROR:', err);
494 } finally {
495 // Close the database when finished.
496 await database.close();
497 }
498 // [END spanner_dml_partitioned_update]
499}
500
501async function deleteUsingPartitionedDml(instanceId, databaseId, projectId) {
502 // [START spanner_dml_partitioned_delete]

Callers 1

dml.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected