Registry / database / mongodb-database-model

mongodb-database-model

JSON →
library2.35.0jsnpmunverified

MongoDB database model class for Compass. Provides a structured representation of a MongoDB database, including collections, indexes, and schema analysis. Version 2.35.0 is the current stable release, part of the MongoDB Compass ecosystem. Built with TypeScript, it offers type-safe database modeling and is used internally by Compass. Infrequently updated, with no known breaking changes in recent versions. Key differentiator: tailored for Compass internal use; not intended for general-purpose MongoDB modeling outside that context.

npm install mongodb-database-model
INSTALL
IMPORT
SIG · MONGODB-DATABASE-M
M
mongodb-database-model
databasejavascriptv2.35.0
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.

Model
✓ import { Model } from 'mongodb-database-model'
Provides the database model class representing a MongoDB database with collections and metadata.
createModel
✓ import { createModel } from 'mongodb-database-model'
✗ import createModel from 'mongodb-database-model'
createModel is a named export, not a default export. Use destructured import.
default
✓ import DatabaseModel from 'mongodb-database-model'
✗ const DatabaseModel = require('mongodb-database-model').default
The package has a default export as well. CJS require (e.g., require('mongodb-database-model')) may require .default in Node <14.

Shows how to import and use the createModel factory to instantiate a DatabaseModel object with collections.

import { createModel } from 'mongodb-database-model'; // Create a model from a database info object const dbModel = createModel({ _id: 'mydb', name: 'mydb', collections: ['users', 'orders'], collection_count: 2, }); console.log(dbModel.name); // 'mydb' console.log(dbModel.collections); // ['users', 'orders']
Debug
Known issues
gotchaThe package is designed for internal use in MongoDB Compass; not recommended for external applications.
fix
Consider using the official MongoDB Node.js driver or mongoose for general-purpose database modeling.
affects: >=0.0.0
deprecatedDeprecated exports like 'DatabaseModel' may be removed in future versions.
fix
Use 'Model' or 'createModel' instead.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: model.collections is not a function
collections is an array property, not a method.
fix
Access model.collections directly (array), not model.collections()
Cannot find module 'mongodb-database-model'
Missing installation.
fix
Run 'npm install mongodb-database-model'
Upgrade
Version history
2.35.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
mongodb-database-model — npm install mongodb-database-model · libregistry