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

Function executePartition

spanner/batch.js:78–111  ·  view source on GitHub ↗
(
  instanceId,
  databaseId,
  identifier,
  partition,
  projectId
)

Source from the content-addressed store, hash-verified

76}
77
78async function executePartition(
79 instanceId,
80 databaseId,
81 identifier,
82 partition,
83 projectId
84) {
85 // [START spanner_batch_execute_partitions]
86 // Imports the Google Cloud client library
87 const {Spanner} = require('@google-cloud/spanner');
88
89 /**
90 * TODO(developer): Uncomment the following lines before running the sample.
91 */
92 // const projectId = 'my-project-id';
93 // const instanceId = 'my-instance';
94 // const databaseId = 'my-database';
95 // const identifier = {};
96 // const partition = {};
97
98 // Creates a client
99 const spanner = new Spanner({
100 projectId: projectId,
101 });
102
103 // Gets a reference to a Cloud Spanner instance and database
104 const instance = spanner.instance(instanceId);
105 const database = instance.database(databaseId);
106 const transaction = database.batchTransaction(identifier);
107
108 const [rows] = await transaction.execute(partition);
109 console.log(`Successfully received ${rows.length} from executed partition.`);
110 // [END spanner_batch_execute_partitions]
111}
112
113require('yargs')
114 .demandCommand(1)

Callers 1

batch.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected