@antelopejs/interface-database-catalog
v0.0.3
Published
AntelopeJS interface for describing and profiling a connected database
Readme
@antelopejs/interface-database-catalog
Describes and profiles a database that an @antelopejs/interface-database provider is connected to but does not own, so a generator can propose a module whose tables mirror it. It is a development tool: every function refuses outside development.
What it offers
Inforeturns the engine, version, database and role of the connection.ListRelationslists every relation with its kind, row estimate, key and write privileges, and says why a relation cannot be registered when it cannot.DescribeRelationsdetails columns with their native types and the@Fielddeclarations they accept, indexes and foreign keys.Profileaggregates a relation per column and per foreign key, never returning rows.CheckReferencemeasures how much of one column's values another column holds, for references the database does not declare.SampleRowsanswers a few rows of a relation, each value as text, for a person to look at; it is the one function that returns rows, and is never meant for a generator or a model.
The answers follow the provider's own registration rules: a relation the catalog calls mappable registers, and the key it names is the one _id aliases.
Implementations
No public module implements this interface yet. A provider of @antelopejs/interface-database that connects to a database it does not own can implement it as well.
Install
The package is not published to npm yet. Once it is, add it to the module that reads the catalog:
pnpm add @antelopejs/interface-database-catalogQuick start
import { ListRelations } from "@antelopejs/interface-database-catalog";
export async function listMappableRelations() {
const relations = await ListRelations(["public"]);
return relations
.filter((relation) => !relation.unmappable)
.map((relation) => `${relation.schema}.${relation.name}`);
}Relations are named "schema.name", the form DescribeRelations and Profile take.
Documentation
Compatibility
Requires AntelopeJS core >=1.14.0 and the following peer dependency:
| Package | Range |
| ---------------------------- | ---------------- |
| @antelopejs/interface-core | >=0.2.4 <1.0.0 |
Contributing
Read CONTRIBUTING.md before you open a pull request. The local checks are:
pnpm install
pnpm lint
pnpm typecheck