Principle:2giosangmitom Sqmeow nvim Schema Discovery
| 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:
- Top level: Schemas (or cluster databases for PostgreSQL/MongoDB/SurrealDB/MSSQL), plus a Roles heading where supported.
- 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).
- Group level: Individual relations or routines.
- 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})