MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / getIdByName

Function getIdByName

console/src/test/sql/getIdByName.ts:23–48  ·  view source on GitHub ↗
(
  params: ClusterSearchParameters | ObjectSearchParameters,
)

Source from the content-addressed store, hash-verified

21
22// This function is used to get the id of an object or cluster by its name.
23export async function getIdByName(
24 params: ClusterSearchParameters | ObjectSearchParameters,
25) {
26 const client = await getMaterializeClient();
27
28 if ("schemaName" in params) {
29 const {
30 rows: [object],
31 } = await client.query(
32 `
33 select id
34 from mz_internal.mz_object_fully_qualified_names
35 where name = '${params.name}' AND
36 schema_name = '${params.schemaName}' AND
37 database_name = '${params.databaseName}'`,
38 );
39
40 return object.id as string;
41 }
42 const {
43 rows: [cluster],
44 } = await client.query(
45 `select id from mz_clusters where name = '${params.name}'`,
46 );
47 return cluster.id as string;
48}

Calls 2

getMaterializeClientFunction · 0.90
queryMethod · 0.45

Tested by

no test coverage detected