Skip to content

novuhq/mongo-to-D2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongo to D2 (M2D2)

Maintained and supported by

D2 Diagrams are very useful know exactly what schemas your database is following. If you have a mongo database that you'd like to diagram, you can use this tool to generate a schema for it.

Here is an example of the output of this tool rendered in Terrastruct.

Example

This Tool Supports

  • Merging the same document referenced in other documents into the same table
  • Recursively mapping Arrays and Documents
  • Mapping only the user generated databases

Installation

  • Clone this repo
  • npm install

Usage

$ node index "mongodb://localhost:27017"

Database Setup

Due to mongo having no actual relational data, we have to rely on the names of fields to get the correlation. Thus a forign reference in Mongo should be of the form "_<collection_name>Id" or "<collection_name>Id" as a field in a document. For example, if we have a collection named "templates" and a document links to its id then we expect the document to contain a field called "_templateId" or "templateId".

Future

We will look in the future to move this tool to a npm distributed cli tool for better maintainability and additional features.

In addition, we will look to support a way to put in custom mapping so your database does not have to change to use this tool.

If you wish to contribute to this tool, Come Join Our Discord and discuss with the team what you would like to do.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published