npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dbml-metaquery

v1.2.0

Published

Parse DBML into a navigable graph with rich metadata -- FK path finding, table info, groups, and schema search.

Readme

dbml-metaquery

Parse DBML into a navigable graph with rich metadata -- FK path finding, table info, groups, and schema search.

Uses @dbml/parse for correct handling of all DBML syntax.

Installation

npm install dbml-metaquery
# or
bun add dbml-metaquery

Library API

import { DbmlGraph } from "dbml-metaquery"
import { readFileSync } from "fs"

const dbml = readFileSync("model.dbml", "utf-8")
const graph = new DbmlGraph(dbml)

Path Finding

graph.findPath("order_items", "users")
// [
//   { from: { table: "order_items", column: "order_id" }, to: { table: "orders", column: "id" } },
//   { from: { table: "orders", column: "user_id" }, to: { table: "users", column: "id" } },
// ]

Table Metadata

graph.getTable("orders")
// {
//   name: "orders",
//   note: "Customer orders",
//   columns: [
//     { name: "id", type: "INTEGER" },
//     { name: "user_id", type: "INTEGER", fk: { table: "users", column: "id" } },
//     { name: "product", type: "VARCHAR", note: "Product name" },
//     ...
//   ]
// }

Navigation

// What tables reference users?
graph.getReferencingTables("users")
// [{ table: "orders", column: "user_id", myColumn: "id" }, ...]

// What's directly connected to orders?
graph.getNeighbors("orders")
// {
//   parents: [{ table: "users", via: "user_id" }],
//   children: [{ table: "order_items", via: "order_id" }]
// }

// Schema overview
graph.getSummary()
// [{ groupName: "people", tableCount: 2, tables: ["users", "departments"] }, ...]

// Search across table/column names and notes
graph.searchSchema("order")
// [{ table: "orders", match: "table_name", text: "orders" }, ...]

Groups and Colors

graph.getGroups()       // all TableGroups with member tables
graph.getGroup("users")  // { name: "people", tables: ["users", "departments"] }
graph.getTableColor("users")  // "#3498db"
graph.getGroupColor("people")  // "#3498db"

Raw Graph Access

const g = graph.getGraph() // graphology Graph copy
g.nodes()                  // all table names
g.edges()                  // all FK edges
g.forEachEdge((edge, attrs) => { /* custom traversal */ })

All Methods

| Method | Returns | Description | |---|---|---| | findPath(from, to) | PathStep[] \| null | Shortest FK path between two tables | | getTables() | string[] | All table names, sorted | | getRelationships(table?) | Relationship[] | FK relationships, optionally filtered | | getTable(name) | TableInfo \| undefined | Table note, columns with types/notes/FKs | | getGroups() | GroupInfo[] | All TableGroups with member tables | | getGroup(tableName) | GroupInfo \| undefined | Which group a table belongs to | | getTableColor(name) | string \| undefined | Table headercolor | | getGroupColor(name) | string \| undefined | Group color | | getReferencingTables(name) | ReferencingTable[] | Tables that FK into this table | | getNeighbors(name) | Neighbors | One-hop parents and children | | getSummary() | GroupSummary[] | Groups with table counts | | searchSchema(query) | SearchResult[] | Substring search across names and notes | | getGraph() | Graph | Copy of the underlying graphology graph for external analysis |

CLI

The first argument is always the path to a .dbml file, followed by a command.

dbml-metaquery model.dbml find-path <from> <to>   # Shortest FK path
dbml-metaquery model.dbml info <table>             # Table metadata
dbml-metaquery model.dbml neighbors <table>        # Directly connected tables
dbml-metaquery model.dbml refs-to <table>          # Tables that FK into this table
dbml-metaquery model.dbml rels <table>             # All FK relationships
dbml-metaquery model.dbml search <query>           # Search names and notes
dbml-metaquery model.dbml summary                  # Schema overview
dbml-metaquery model.dbml tables                   # List all tables

License

MIT