Registry / devops / mongodb-models-visualizer

mongodb-models-visualizer

JSON →
library0.1.18jsnpmunverified

MongoDB-models-visualizer (v0.1.18) is a developer tool for Node.js/Express applications using Mongoose (v6+) that automatically introspects all registered Mongoose models and serves both a Swagger-like web UI and JSON API endpoints. It extracts schema fields, types, validations, references (ref), and collection names, and optionally includes sample documents. Unlike generic MongoDB GUIs, it integrates directly into an Express server as middleware, providing a live view of the current model state without external services. Current release cadence is irregular; it is an early-stage project with roadmap for v0.2 and v1.0.

npm install mongodb-models-visualizer
INSTALL
IMPORT
SIG · MONGODB-MODELS-VIS
M
mongodb-models-visualizer
devopsjavascriptv0.1.18
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

modelAnalyzer
import { modelAnalyzer } from 'mongodb-models-visualizer'
const { modelAnalyzer } = require('mongodb-models-visualizer')
Package ships TypeScript types and is ESM-first. CJS require may fail in some bundlers; use ESM import or dynamic import.
default
import { modelAnalyzer } from 'mongodb-models-visualizer'
import modelAnalyzer from 'mongodb-models-visualizer'
There is no default export; only named export modelAnalyzer.
Mongoose
import mongoose from 'mongoose'
import { mongoose } from 'mongoose'
Mongoose is a default export; the peer dependency is the entire mongoose object.

Mount modelAnalyzer middleware on an Express app, connect Mongoose, and access the UI at /models-analyzer.

import express from 'express'; import mongoose from 'mongoose'; import { modelAnalyzer } from 'mongodb-models-visualizer'; const app = express(); const MONGO_URI = process.env.MONGO_URI || 'mongodb://localhost:27017/test'; mongoose.connect(MONGO_URI).then(() => { console.log('MongoDB connected'); }).catch(err => { console.error(err); }); app.use('/models-analyzer', modelAnalyzer({ mongoose })); app.listen(3000, () => { console.log('Server running on http://localhost:3000'); });
Debug
Known issues
gotchaThe middleware must be mounted after Mongoose models are registered; otherwise no models will be detected.
fix
Ensure all Mongoose model definitions are required/imported before mounting the middleware.
affects: >=0.1
gotchaThe 'auth' option is not implemented as authentication middleware; setting auth: true does nothing. Use external auth middleware instead.
fix
Do not rely on the auth option. Wrap the middleware with a separate auth middleware (e.g., express-basic-auth).
affects: 0.1.0 - 0.1.18
deprecatedThe 'sampleDocs' option may add performance overhead on large collections as it queries sample documents.
fix
Only enable sampleDocs in development environments.
affects: >=0.1
gotchaExposing this endpoint publicly without authentication can leak your database schema and sample data.
fix
Always protect the /models-analyzer route with authentication in production.
affects: >=0.1
Errors
Common errors & fixes
Cannot find module 'mongodb-models-visualizer'
Package not installed or npm install failed.
fix
Run 'npm install mongodb-models-visualizer' and ensure node_modules contains it.
TypeError: mongoose is not a function
modelAnalyzer expects a mongoose instance object, not a function.
fix
Pass the mongoose object: modelAnalyzer({ mongoose: mongoose }) or use shorthand { mongoose }.
Error: No Mongoose models found
Middleware mounted before models are defined/imported.
fix
Import/require all Mongoose model files before mounting the middleware.
Upgrade
Version history
0.1.18latest on npm
Audit
Dependencies
expressrequiredrequired peer dependency for mounting middleware
mongooserequiredrequired peer dependency to introspect models
Agent activity
12 hits · last 30 days
node
10
Bingbot
1
Resources