A CLI tool to seamlessly generate and manage MongoDB schemas in Node.js using visual database designs created on DBDraw.
The DBDraw CLI bridges the gap between database visualization and backend development. With this tool, you can:
- Design your database schema visually on DBDraw, where nodes represent collections and edges define relationships.
- Sync the schemas directly into your local project with just a few commands.
- Save development time and ensure your database structure stays consistent and maintainable.
Install the DBDraw CLI globally using npm:
npm install -g dbdraw
-
Visual Database Design
Design your database structure visually using DBDraw, where:- Nodes represent collections.
- Edges represent relationships between collections.
-
Schema Generation
Automatically generate MongoDB schemas from your DBDraw designs, saving time and reducing manual errors. -
TypeScript Support
Choose between JavaScript or TypeScript schema generation for improved type safety and code quality. -
Custom Configuration
Configure options such as:- Module system: CommonJS or ESM.
- Output directory for generated models.
-
Synchronization
Keep your local schemas updated with the latest changes made on DBDraw using thesync
command.
- Visit DBDraw and sign up or log in to your account.
- Start a new design:
- Add nodes to represent collections.
- Use edges to define relationships between collections.
- Save your design for future use.
- Navigate to the Settings section in your DBDraw account.
- Generate a new Access Token.
- Copy the token for authentication in the CLI.
Authenticate yourself by pasting the access token into the CLI when prompted.
dbdraw login
Select a project from your DBDraw account and link it to your local Node.js project.
dbdraw link
After linking, set up the following configurations for your project:
- Select the module system (e.g., CommonJS or ESM).
- Choose the language (TypeScript or JavaScript).
- Define the path where the schemas should be generated.
Once everything is configured, sync your local project to download the schemas generated from your DBDraw design.
dbdraw sync