getMetadata

Understanding the getMetadata method

getMetadata(connection: Connection): Promise<Table[]>

Description: Fetches the metadata (tables and columns) from the database based on the provided connection details

  • Parameters:

    • connection (Connection): A Connection object containing database connection details.

  • Returns:

    • A Promise that resolves to an array of Table objects or rejects with an SQLError.

Example:

client.getMetadata({
  id: "1",
  name: "Chinook",
  host: "localhost",
  port: 5432,
  user: "postgres",
  password: "password",
  database: "chinook",
  type: DatabaseType.POSTGRES
}).then((tables) => {
  console.log(tables);
}).catch((error) => {
  console.error(error);
});

Last updated