The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
group columns ahead of time
Bobbie Soedirgofdb5fb57cec4
diff --git a/studio/stores/pgmeta/ForeignTableStore.ts b/studio/stores/pgmeta/ForeignTableStore.tsindex b216e7131b1..84710e16e7a 100644--- a/studio/stores/pgmeta/ForeignTableStore.ts+++ b/studio/stores/pgmeta/ForeignTableStore.ts@@ -37,9 +37,15 @@ export default class ForeignTableStore extends PostgresMetaInterface<Partial<Posif (columnsResponse.error) throw columnsResponse.error// merge 2 response to create the final array+ const columnsByTableId = (columnsResponse as PostgresColumn[])+ .reduce((acc, curr) => {+ acc[curr.table_id] ??= []+ acc[curr.table_id].push(curr)+ return acc+ }, {} as Record<string, PostgresColumn[]>)const foreignTables: PostgresTable[] = []foreignTablesResponse.forEach((foreignTable: PostgresTable) => {- const columns = columnsResponse.filter((x: PostgresColumn) => x.table_id === foreignTable.id)+ const columns = columnsByTableId[foreignTable.id]foreignTables.push({ ...foreignTable, columns })})diff --git a/studio/stores/pgmeta/MaterializedViewStore.ts b/studio/stores/pgmeta/MaterializedViewStore.tsindex 9b2d0ed77c2..71a98dc43df 100644--- a/studio/stores/pgmeta/MaterializedViewStore.ts+++ b/studio/stores/pgmeta/MaterializedViewStore.ts@@ -39,9 +39,15 @@ export default class MaterializedViewStore extends PostgresMetaInterface<Postgreif (columnsResponse.error) throw columnsResponse.error// merge 2 response to create the final array+ const columnsByTableId = (columnsResponse as PostgresColumn[])+ .reduce((acc, curr) => {+ acc[curr.table_id] ??= []+ acc[curr.table_id].push(curr)+ return acc+ }, {} as Record<string, PostgresColumn[]>)const materializedViews: PostgresMaterializedView[] = []materializedViewsResponse.forEach((materializedView: PostgresMaterializedView) => {- const columns = columnsResponse.filter((x: PostgresColumn) => x.table_id === materializedView.id)+ const columns = columnsByTableId[materializedView.id]materializedViews.push({ ...materializedView, columns })})diff --git a/studio/stores/pgmeta/TableStore.ts b/studio/stores/pgmeta/TableStore.tsindex 7571e848bd7..f6da9e1807d 100644--- a/studio/stores/pgmeta/TableStore.ts+++ b/studio/stores/pgmeta/TableStore.ts@@ -42,10 +42,15 @@ export default class TableStore extends PostgresMetaInterface<PostgresTable> {if (columnsResponse.error) throw columnsResponse.error// merge 2 response to create the final array+ const columnsByTableId = (columnsResponse as PostgresColumn[])+ .reduce((acc, curr) => {+ acc[curr.table_id] ??= []+ acc[curr.table_id].push(curr)+ return acc+ }, {} as Record<string, PostgresColumn[]>)const tables: PostgresTable[] = []tablesResponse.forEach((table: PostgresTable) => {- const tableId = table.id- const columns = columnsResponse.filter((x: PostgresColumn) => x.table_id === tableId)+ const columns = columnsByTableId[table.id]tables.push({ ...table, columns })})diff --git a/studio/stores/pgmeta/ViewStore.ts b/studio/stores/pgmeta/ViewStore.tsindex ae83f4482c4..063530b2390 100644--- a/studio/stores/pgmeta/ViewStore.ts+++ b/studio/stores/pgmeta/ViewStore.ts@@ -37,9 +37,15 @@ export default class ViewStore extends PostgresMetaInterface<SchemaView> {if (columnsResponse.error) throw columnsResponse.error// merge 2 response to create the final array+ const columnsByTableId = (columnsResponse as PostgresColumn[])+ .reduce((acc, curr) => {+ acc[curr.table_id] ??= []+ acc[curr.table_id].push(curr)+ return acc+ }, {} as Record<string, PostgresColumn[]>)const views: PostgresView[] = []viewsResponse.forEach((view: PostgresView) => {- const columns = columnsResponse.filter((x: PostgresColumn) => x.table_id === view.id)+ const columns = columnsByTableId[view.id]views.push({ ...view, columns })})