MongoDB Index Modeler

☰ menu
× Create Model Clear Model Load from File Save to File

MongoDB Index Modeler

Introduction

The MongoDB Index Modeler is a browser-based tool for designing and visualizing MongoDB data structures. It helps you create document-oriented data models, define schemas, and experiment with different indexing strategies. The tool runs entirely in your browser, storing data locally in memory for rapid prototyping without requiring server infrastructure.

Key Concepts

Document Types

Each document must have a "type" attribute that defines its schema. When you set a document's type, the Index Modeler automatically adds all attributes associated with that type.

Indexes

The primary view displays documents sorted by their "_id" field. Additional indexes can be created to visualize how documents would be organized with different access patterns.

Array Expansion

When an index includes an array field, MongoDB creates an index entry for each array element. The Index Modeler visualizes this expansion to help understand multi-key index behavior.

Value Templates

Value templates allow for dynamic generation of field values based on other fields in the document. Use ${fieldName} syntax to reference other fields.

Getting Started

1. Create a Model

  • Click the "☰ menu" button in the top-right corner
  • Select "Create Model" from the dropdown
  • Enter a Name, Author, and Description for your model
  • Provide a name for your first Collection
  • Click "Create"

2. Working with Documents

  • Add a Document: Click the "+" button in the "Index Keys" cell header
  • Edit Document ID: Click the "_id" cell and enter a unique identifier
  • Set Document Type: Click the "type" cell and enter a type name
  • Add Attributes: Right-click and select "Add Attribute" or click the existing "~new~" attribute cell
  • Edit Complete Document: Click the pencil icon next to a document ID to open the JSON editor

3. Creating Indexes

  • Click the "+" button in the upper-right corner of the collection tab
  • Enter a comma-separated list of attributes to index
  • Provide a name for your index
  • The new index will appear as a tab above the table view

4. Editing Document Values

  • Simple Values: Click on any cell to edit its value directly
  • Complex Values: Click the pencil icon or the "{...}" cell for nested objects or arrays
  • Value Templates: Right-click on an attribute cell and select "Edit Value Template"
  • Generate Values: Right-click on a cell and use the "Generate Value" options

5. Common Operations

  • Undo Changes: Click the "↩" button at the top of the "Attributes" column
  • Delete Document: Click the trash icon next to a document ID
  • Clone Attributes: In the JSON editor, right-click and select "Clone Attributes" to copy attributes from another document
  • Toggle View: Switch between value and schema views to see different perspectives

Tips & Advanced Features

  • Use context menus (right-click) for quick access to document operations
  • Value Templates can be used to automatically generate values based on other fields (e.g., ${firstName} ${lastName})
  • Array Fields in indexes will expand to show how MongoDB creates separate index entries for each array element
  • For complex hierarchical data, use nested documents and dot notation in index definitions
  • Export your model to a file for later use or sharing with teammates

Sample Models

To see a demonstration of the tool in action, you can view this sample model of an adjacency list, which illustrates multi-key indexes and document relationships:

Sample model screenshot Sample model index view screenshot