mongo-auto-erd
TypeScript icon, indicating that this package has built-in type declarations

1.0.15 • Public • Published

Test Coverage Blazing Fast

mongo-auto-erd

This is an Entity Relationship Diagram generator for MongoDB databases. Given a connection url, it performs reverse engineering by map reducing db collections into a well defined interface with properties and it's relationships.

Caveats

This lib will only generate .svg, .png and .dot formats if graphviz is installed. Graphviz is a quasi standart library to generate graphs, their creators proposed the .dot language for graph representations, I opted to use it because it is compatible or convertible to many graph editing platforms.

If you don't want to use graphviz, the software will output a well defined ERD interface:

export interface IEntity {
  name: string
  properties: IProperty[]
  relationships: IRelationship[]
}
 
export interface IProperty extends IMapReducedProperty {
  types: IPropertyType[]
}
 
export type IPropertyType = 
  | 'string'
  | 'undefined'
  | 'null'
  | 'number'
  | 'objectId'
  | 'boolean'
  | 'unknown'
  | 'array'
  | 'function'
  | 'symbol'
  | 'bigint'
  | 'object'
 
export interface IRelationship {
  propertyNames: string[]
  targetCollectionName: string
}
 
export interface IMapReducedProperty {
  name: string
  values: any[]
}

Example .json output

Usage

mongo-erd --uri mongodb://127.0.0.1:27017 --db dbname --outfile ./erd

This command will produce a result like

Example .png diagram

Package Sidebar

Install

npm i mongo-auto-erd

Weekly Downloads

3

Version

1.0.15

License

MIT

Unpacked Size

227 kB

Total Files

96

Last publish

Collaborators

  • lvdalcin