const TableView: Component<{
table?: DatabaseTable;
connection: DatabaseConnection;
class?: string;
}> = (props) => {
const [tableData] = createResource(
() => props.table,
async (table) => {
console.log("table changed");
if (!table) return;
const res: TableData = await window.api.sendSqlQuery(
`SELECT * FROM ${table.schema}.${table.tableName} LIMIT 40`,
{
host: props.connection.host,
port: props.connection.port,
user: props.connection.user,
password: props.connection.password,
database: props.connection.database,
}
);
return res;
}
);
...
return (
<Show when={tableData() && props.table}>
<h1 class="text-xl font-medium p-4">{props.table!.tableName}</h1>
<DataTable data={tableData()!} />
</Show>
);
}
const TableView: Component<{
table?: DatabaseTable;
connection: DatabaseConnection;
class?: string;
}> = (props) => {
const [tableData] = createResource(
() => props.table,
async (table) => {
console.log("table changed");
if (!table) return;
const res: TableData = await window.api.sendSqlQuery(
`SELECT * FROM ${table.schema}.${table.tableName} LIMIT 40`,
{
host: props.connection.host,
port: props.connection.port,
user: props.connection.user,
password: props.connection.password,
database: props.connection.database,
}
);
return res;
}
);
...
return (
<Show when={tableData() && props.table}>
<h1 class="text-xl font-medium p-4">{props.table!.tableName}</h1>
<DataTable data={tableData()!} />
</Show>
);
}