Skip to content

StructureView ​

The columns, indexes, foreign keys and DDL of one table or view, in four read only tabs. To change a table, use TableDesigner.

tsx
import { StructureView } from '@adecore/database';
tsx
import { StructureView } from '@adecore/database';
import { ShopDatabase } from '../shared/database.tsx';
import { SHOP } from '../shared/shop.ts';

export default function StructureViewDemo() {
    return (
        <ShopDatabase>
            <div className="flex h-80 w-full overflow-hidden rounded-lg border border-border bg-surface">
                <StructureView connection={SHOP} schema="main" table="orders" className="min-w-0 flex-1" />
            </div>
        </ShopDatabase>
    );
}
tsx
<StructureView connection={connection} schema="main" table="orders" className="h-full" />
  • Columns lists the declared type, nullability, default, Auto increment or Generated, and comment.
  • Indexes lists the name, columns and kind: Primary, Unique, or blank.
  • Foreign keys lists the name, columns, referenced table and columns, and On update and On delete. An engine-decided action reads Default.
  • DDL shows the server's CREATE statement, with a Copy button.

toolbarStart draws the app's content before the tabs, as in TableView.

The view reloads when its props change and after a schema change for its schema, keeping the old structure until the new one arrives. A failed load shows the message with Try again.

Props ​

PropTypeDefault
connectionConnectionRequired. The connection the table is in.
schemastringRequired. The schema of the table.
tablestringRequired. The table or view.
toolbarStartReactNodeThe app's own content before the tabs.
classNamestringIts size.
refRef<HTMLDivElement>

The props are StructureViewProps. The view needs a DatabaseProvider above it.

Licenses and third-party notices are listed in each package.