The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: improve pgmeta tables fetchData
phamhieub8dc6a10df13
diff --git a/studio/stores/pgmeta/TableStore.ts b/studio/stores/pgmeta/TableStore.tsindex 5063db74c65..dec9b66cc9d 100644--- a/studio/stores/pgmeta/TableStore.ts+++ b/studio/stores/pgmeta/TableStore.ts@@ -1,5 +1,5 @@import { action, makeObservable } from 'mobx'-import type { PostgresTable } from '@supabase/postgres-meta'+import type { PostgresColumn, PostgresTable } from '@supabase/postgres-meta'import PostgresMetaInterface, { IPostgresMetaInterface } from '../common/PostgresMetaInterface'import { IRootStore } from '../RootStore'@@ -25,6 +25,34 @@ export default class TableStore extends PostgresMetaInterface<PostgresTable> {})}+ // Customize TableStore fetchData method to improve request performance+ async fetchData() {+ const headers = { 'Content-Type': 'application/json', ...this.headers }+ // load all tables w/o columns info+ const urlTables = this.url.includes('?')+ ? `${this.url}&include_columns=false`+ : `${this.url}?include_columns=false`+ // load all columns+ const urlColumns = this.url.replace('/tables', '/columns')+ const [tablesResponse, columnsResponse] = await Promise.all([+ get(urlTables, { headers }),+ get(urlColumns, { headers }),+ ])+ if (tablesResponse.error) throw tablesResponse.error+ if (columnsResponse.error) throw columnsResponse.error++ // merge 2 response to create the final array+ const tables: PostgresTable[] = []+ tablesResponse.forEach((table: PostgresTable) => {+ const tableId = table.id+ const columns = columnsResponse.find((x: PostgresColumn) => x.table_id === tableId)+ tables.push({ ...table, columns })+ })++ this.setDataArray(tables)+ return tables as any+ }+async loadById(id: number | string) {try {const url = this.url.includes('?') ? `${this.url}&id=${id}` : `${this.url}?id=${id}`