import { DSQL_ChildrenTablesType, DSQL_TableSchemaType } from "../../../types"; type Params = { tables?: DSQL_TableSchemaType[]; tableSchema?: DSQL_TableSchemaType; childTableSchema?: DSQL_ChildrenTablesType; tableName?: string; }; export default function grabTargetTableSchemaIndex({ tables, tableName, tableSchema, childTableSchema, }: Params): number | undefined { if (!tables) return undefined; const targetTableIndex = tables.findIndex( (tbl) => (tableName && tableName == tbl.tableName) || (tableSchema && tableSchema.tableName && tableSchema.tableName == tbl.tableName) ); if (targetTableIndex < 0) return undefined; return targetTableIndex; }