Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:2giosangmitom Sqmeow nvim Schema Discovery

From Leeroopedia
Knowledge Sources
Domains Schema, Database
Last Updated 2026-10-16 14:00 GMT

Overview

A metadata discovery principle that reads catalog structure — schemas, relations, columns, indexes, routines, roles — through a uniform adapter interface for display in the editor's schema drawer.

Description

Schema Discovery is the principle of querying the database catalog through the Adapter trait's metadata methods and presenting the results as a tree of nodes for the editor's schema drawer. The tree is at most 3 levels deep: connection → schemas → groups → relations/columns. Each level is fetched lazily as the user expands nodes.

This principle addresses the challenge of presenting heterogeneous database catalogs (SQL schemas, MongoDB databases/collections, Redis key spaces) through a single tree UI. The adapter translates its native catalog format into uniform node types (SchemaNode, RelationNode, ColumnNode, IndexNode, RoutineNode, RoleNode). The engine groups relations by kind (Tables, Views, Functions, Procedures, Sequences, Packages) and handles dialect-specific structure (MongoDB has Collections/Views, Redis groups by key type).

Usage

Use this principle when a database tool needs to show the catalog structure of any supported backend through a single tree UI. Each adapter implements the metadata methods; the engine handles grouping and presentation.

Theoretical Basis

The principle uses lazy tree expansion with adapter-translated catalog metadata:

  1. Top level: Schemas (or cluster databases for PostgreSQL/MongoDB/SurrealDB/MSSQL), plus a Roles heading where supported.
  2. Schema level: Groups by relation kind — Tables, Views, Functions, Procedures, Sequences, Packages — with counts. Redis groups by key type (String, Hash, Set, List, Sorted Set, JSON, Stream, Keys).
  3. Group level: Individual relations or routines.
  4. Relation level: Columns with type, nullability, key flags, foreign keys, defaults; plus indexes and table details (comments, constraints, triggers, definition).
# Abstract pattern (NOT real implementation):
async def read_level(connection, path, pattern):
    if not path:
        nodes = connection.backend.schemas()  # or databases()
    elif len(path) == 1:
        relations = connection.backend.relations(path[0])
        nodes = group_by_kind(relations)  # Tables, Views, Functions...
    elif len(path) == 3:
        nodes = connection.backend.columns(path[0], path[2])
    emit("schema:nodes", {conn_id, path, nodes})

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment