# Variable discovery

discovery: {
discover_tables: (
tableNames: string[],
schema0?: string,
dbModule?: DbExportsType,
) => Promise<{ tables: TablePack[] }>;
discoverable_tables: (
schema0?: string,
allTables?: boolean,
dbModule?: DbExportsType,
) => Promise<Row[]>;
findType: (sql_name: string) => string | undefined;
get_existing_views: (schema0?: string) => Promise<Row[]>;
implement_discovery: (pack: { tables: TablePack[] }) => Promise<void>;
}

#### Type Declaration

- ##### discover_tables: (
  tableNames: string[],
  schema0?: string,
  dbModule?: DbExportsType,
  ) => Promise<{ tables: TablePack[] }>

  Discover tables definitions

- ##### discoverable_tables: (
  schema0?: string,
  allTables?: boolean,
  dbModule?: DbExportsType,
  ) => Promise<Row[]>

  List of discoverable tables. Returns all tables that can be imported to Saltcorn from current tenant database schema. The tables with name started with "sc" and tables imported to Saltcorn are ignored.

- ##### findType: (sql_name: string) => string | undefined

  Mapping SQL Type to Saltcorn type (For Discovery)

- ##### get_existing_views: (schema0?: string) => Promise<Row[]>

  List all views in current tenant db schema

- ##### implement_discovery: (pack: { tables: TablePack[] }) => Promise<void>

  Add discovered tables to Saltcorn

- Defined in packages/saltcorn-data/models/discovery.ts:290