Gathering detailed insights and metrics for mongo-diagram-builder
Gathering detailed insights and metrics for mongo-diagram-builder
Gathering detailed insights and metrics for mongo-diagram-builder
Gathering detailed insights and metrics for mongo-diagram-builder
npm install mongo-diagram-builder
Typescript
Module System
Node Version
NPM Version
58.1
Supply Chain
96.4
Quality
76.1
Maintenance
100
Vulnerability
99.6
License
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
150%
5
Compared to previous week
Last Month
44.4%
13
Compared to previous month
Last Year
0%
1,043
Compared to previous year
Create automatic mongo UMLs diagrams from your MongoDB database schema.
1npm i -g mongo-diagram-builder
mongo-diagram-builder.config.js
file with the following content:1module.exports = { 2 sourceDir: './your-mongodb-schema-directory', // Change this to the directory containing your MongoDB schema files 3 fileExtension: '.schema.js', // Change this to the file extension of your MongoDB schema files 4 outputDir: './your-output-directory', // Change this to the directory where you want to save the generated UML diagrams 5 outputFileName: 'diagram-name-file', // Change this to the desired output file name 6}
mongo-diagram-builder
command line after creating the configuration file:1npx mongo-diagram-builder create
This will generate a UML diagram for each MongoDB collection in the specified directory, and save them in the specified output directory with the provided output file name with MarkDown extension.
Task
, User
, Project
, and Comment
. They follow the standard mongoose structure as represented below:1@Schema({ collection: 'comments', timestamps: true }) 2export class Comment extends Document { 3 @Prop({ required: true, type: Schema.Types.ObjectId, ref: 'Task' }) 4 taskId: string; 5 6 @Prop({ required: true, type: Schema.Types.ObjectId, ref: 'User' }) 7 userId: string; 8 9 @Prop({ required: true }) 10 content: string; 11 12 @Prop({ default: Date.now }) 13 createdAt: Date; 14} 15 16export const CommentSchema = SchemaFactory.createForClass(Comment);
The schema for all tables in this example will be created in a schema
folder as shown below, but it is not necessary for all schemas to be in this folder. They can be separated within an application module; in this case, you would point to the main project folder.
Obs: Relations must follow the 'nameClassId' pattern, if the property does not follow this pattern the code will not understand the relations
mongo-diagram-builder.config.js
file with the settings:After running the command mongo-diagram-builder create
, you will see the generated UML diagram in ./
with the name example-diagram.md
.
Diagram generated example:
If you want relations yourn classes, follow the mermaid sintax founded in Mermaid Documentation. for example:
1classDiagram 2classA <|-- classB 3classC *-- classD 4classE o-- classF 5classG <-- classH 6classI -- classJ 7classK <.. classL 8classM <|.. classN 9classO .. classP 10classQ "n" <--o "1" classR 11classS "1" o--o "1" classT
1classDiagram
2classA <|-- classB
3classC *-- classD
4classE o-- classF
5classG <-- classH
6classI -- classJ
7classK <.. classL
8classM <|.. classN
9classO .. classP
10classQ "n" <--o "1" classR
11classS "1" o--o "1" classT
Diogo Gallina |
No vulnerabilities found.