From 8c0ba6e2e1992373e202719edc07731f6dffd5dd Mon Sep 17 00:00:00 2001 From: Adam Christopher Smith Date: Fri, 26 Dec 2025 22:37:58 -0800 Subject: [PATCH] Use table def accessorName instead of server table name to access table db view --- crates/bindings-typescript/src/react/useTable.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/bindings-typescript/src/react/useTable.ts b/crates/bindings-typescript/src/react/useTable.ts index fb0eb70f68a..fda88a0835f 100644 --- a/crates/bindings-typescript/src/react/useTable.ts +++ b/crates/bindings-typescript/src/react/useTable.ts @@ -268,6 +268,7 @@ export function useTable( ): [readonly Prettify>[], boolean] { type UseTableRowType = RowType; const tableName = tableDef.name; + const accessorName = tableDef.accessorName; let whereClause: Expr> | undefined; if ( whereClauseOrCallbacks && @@ -313,7 +314,7 @@ export function useTable( if (!connection) { return [[], false]; } - const table = connection.db[tableName]; + const table = connection.db[accessorName]; const result: readonly Prettify[] = whereClause ? (Array.from(table.iter()).filter(row => evaluate(whereClause, row as UseTableRowType) @@ -321,7 +322,7 @@ export function useTable( : (Array.from(table.iter()) as Prettify[]); return [result, subscribeApplied]; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [connectionState, tableName, whereKey, subscribeApplied]); + }, [connectionState, accessorName, whereKey, subscribeApplied]); useEffect(() => { const connection = connectionState.getConnection()!; @@ -412,7 +413,7 @@ export function useTable( return () => {}; } - const table = connection.db[tableName]; + const table = connection.db[accessorName]; table.onInsert(onInsert); table.onDelete(onDelete); table.onUpdate?.(onUpdate); @@ -426,7 +427,7 @@ export function useTable( // eslint-disable-next-line react-hooks/exhaustive-deps [ connectionState, - tableName, + accessorName, whereKey, callbacks?.onDelete, callbacks?.onInsert,