Home / Function/ formatAllEntities() — supabase Function Reference

formatAllEntities() — supabase Function Reference

Architecture documentation for the formatAllEntities() function in Tables.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  41ffbcfa_1df7_ad96_f161_7269656b70f5["formatAllEntities()"]
  60b33a3e_c90b_00bb_64e3_60807774634b["TableList()"]
  60b33a3e_c90b_00bb_64e3_60807774634b -->|calls| 41ffbcfa_1df7_ad96_f161_7269656b70f5
  style 41ffbcfa_1df7_ad96_f161_7269656b70f5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Database/Tables/Tables.utils.ts lines 7–72

export const formatAllEntities = ({
  tables = [],
  views = [],
  materializedViews = [],
  foreignTables = [],
}: {
  tables?: PostgresTable[]
  views?: PostgresView[]
  materializedViews?: PostgresMaterializedView[]
  foreignTables?: PostgresForeignTable[]
}) => {
  const formattedTables = tables.map((x) => {
    return {
      ...x,
      type: ENTITY_TYPE.TABLE as const,
      rows: x.live_rows_estimate,
      columns: x.columns ?? [],
    }
  })

  const formattedViews = views.map((x) => {
    return {
      type: ENTITY_TYPE.VIEW as const,
      id: x.id,
      name: x.name,
      comment: x.comment,
      schema: x.schema,
      rows: undefined,
      size: undefined,
      columns: x.columns ?? [],
    }
  })

  const formattedMaterializedViews = materializedViews.map((x) => {
    return {
      type: ENTITY_TYPE.MATERIALIZED_VIEW as const,
      id: x.id,
      name: x.name,
      comment: x.comment,
      schema: x.schema,
      rows: undefined,
      size: undefined,
      columns: x.columns ?? [],
    }
  })

  const formattedForeignTables = foreignTables.map((x) => {
    return {
      type: ENTITY_TYPE.FOREIGN_TABLE as const,
      id: x.id,
      name: x.name,
      comment: x.comment,
      schema: x.schema,
      rows: undefined,
      size: undefined,
      columns: x.columns ?? [],
    }
  })

  return [
    ...formattedTables,
    ...formattedViews,
    ...formattedMaterializedViews,
    ...formattedForeignTables,
  ].sort((a, b) => a.name.localeCompare(b.name))
}

Subdomains

Called By

Frequently Asked Questions

What does formatAllEntities() do?
formatAllEntities() is a function in the supabase codebase.
What calls formatAllEntities()?
formatAllEntities() is called by 1 function(s): TableList.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free