{"id":27151,"library":"mongodb-database-model","title":"MongoDB Database Model","description":"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.","status":"active","version":"2.35.0","language":"javascript","source_language":"en","source_url":"https://github.com/mongodb-js/compass","tags":["javascript","mongodb-js","typescript"],"install":[{"cmd":"npm install mongodb-database-model","lang":"bash","label":"npm"},{"cmd":"yarn add mongodb-database-model","lang":"bash","label":"yarn"},{"cmd":"pnpm add mongodb-database-model","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Provides the database model class representing a MongoDB database with collections and metadata.","symbol":"Model","correct":"import { Model } from 'mongodb-database-model'"},{"note":"createModel is a named export, not a default export. Use destructured import.","wrong":"import createModel from 'mongodb-database-model'","symbol":"createModel","correct":"import { createModel } from 'mongodb-database-model'"},{"note":"The package has a default export as well. CJS require (e.g., require('mongodb-database-model')) may require .default in Node <14.","wrong":"const DatabaseModel = require('mongodb-database-model').default","symbol":"default","correct":"import DatabaseModel from 'mongodb-database-model'"}],"quickstart":{"code":"import { createModel } from 'mongodb-database-model';\n\n// Create a model from a database info object\nconst dbModel = createModel({\n  _id: 'mydb',\n  name: 'mydb',\n  collections: ['users', 'orders'],\n  collection_count: 2,\n});\n\nconsole.log(dbModel.name); // 'mydb'\nconsole.log(dbModel.collections); // ['users', 'orders']\n","lang":"typescript","description":"Shows how to import and use the createModel factory to instantiate a DatabaseModel object with collections."},"warnings":[{"fix":"Consider using the official MongoDB Node.js driver or mongoose for general-purpose database modeling.","message":"The package is designed for internal use in MongoDB Compass; not recommended for external applications.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use 'Model' or 'createModel' instead.","message":"Deprecated exports like 'DatabaseModel' may be removed in future versions.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.35.0':25 'analysi':23 'break':58 'built':37 'chang':59 'class':7 'collect':19 'compass':9,35,52,67 'context':80 'current':28 'databas':2,5,17,45 'differenti':64 'ecosystem':36 'general':74 'general-purpos':73 'includ':18 'index':20 'infrequ':53 'intend':71 'intern':50,68 'javascript':81 'js':84 'key':63 'known':57 'model':3,6,46,77 'mongodb':1,4,16,34,76,83 'mongodb-j':82 'offer':41 'outsid':78 'part':31 'provid':10 'purpos':75 'recent':61 'releas':30 'represent':13 'safe':44 'schema':22 'stabl':29 'structur':12 'tailor':65 'type':43 'type-saf':42 'typescript':39,85 'updat':54 'use':49,69 'version':24,62","created_at":"2026-05-01T17:44:47.154340+00:00","updated_at":"2026-05-01T17:44:47.154340+00:00","problems":[{"fix":"Access model.collections directly (array), not model.collections()","cause":"collections is an array property, not a method.","error":"TypeError: model.collections is not a function"},{"fix":"Run 'npm install mongodb-database-model'","cause":"Missing installation.","error":"Cannot find module 'mongodb-database-model'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/mongodb-js/compass","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/mongodb-database-model","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-04-25","next_check":"2026-07-24","install_tag":null}}