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

Function getDatabaseRoles

spanner/get-database-roles.js:44–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42 const databaseAdminClient = spanner.getDatabaseAdminClient();
43
44 async function getDatabaseRoles() {
45 try {
46 const dbPath = databaseAdminClient.databasePath(
47 projectId,
48 instanceId,
49 databaseId
50 );
51
52 // Fetching database roles
53 const [databaseRoles] = await databaseAdminClient.listDatabaseRoles({
54 parent: dbPath,
55 });
56
57 console.log(`Roles for Database: ${dbPath}`);
58 databaseRoles.forEach(role => {
59 console.log(`Role: ${role.name}`);
60 });
61 } catch (err) {
62 console.error('Error listing database roles:', err);
63 } finally {
64 spanner.close();
65 }
66 }
67 await getDatabaseRoles();
68 // [END spanner_list_database_roles]
69}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected