MongoDB Features

DbSchema can connect to MongoDB and reverse-engineer collection validation rules into its own model. The validation rule is a JSON description of the expected document structure. Creating or editing collections in DbSchema saves the validation rule both to the database and to the local model file.

Diagrams

The validation schema is represented graphically as a diagram. Each collection is a node; field types and nested structures are shown as the collection's body.

  • Edit a collection's validation rule by double-clicking its header
  • Create a new collection to generate the corresponding validation rule in the database
  • Save the model file to persist all diagram layouts and collection definitions

The diagram provides an at-a-glance view of your entire MongoDB schema, including nested documents and arrays.

Visual Query Editor

The visual query editor lets you build MongoDB queries using the mouse. It supports:

  • Filters — add match conditions on any field
  • Projections — select which fields to include or exclude
  • Aggregation pipeline — chain aggregation stages visually

The generated query is shown on the right side of the query editor and can be copied or executed directly.

HTML5 Schema Documentation

Add comments to collections and fields by double-clicking them in the diagram. DbSchema can export the schema as:

  • Interactive HTML5 documentation — includes a vector diagram image and field comments readable as mouse-over tooltips
  • PDF — for offline distribution

Data Generator

Use the Data Generator to populate MongoDB collections with test data. Supported patterns include:

  • Pre-configured patterns from the pattern repository (names, addresses, dates, etc.)
  • Reverse regular expressions for generating structured strings
  • Groovy scripts for fully custom document generation, including nested objects and arrays

Compare Virtual Schema

DbSchema maintains a local copy (the virtual schema) of the database structure. You can connect to a second MongoDB instance and compare its structure against the current model to identify differences and synchronise schemas between environments.

Query Editor

The Query Editor supports native MongoDB query syntax. Use db to reference the currently connected database, or specify the database name directly to query across multiple databases:

use sampleDb
db.employees.find()
db.employees.find({"firstName": {"$regex": "^AL", "$options": "i"}})
db.employees.find({"firstName": {"$regex": "(?i)^AL"}})

Alternatively, reference the database by name:

sampleDb.employees.find()
sampledb.getCollection('employees').find()

Additional commands supported in the Query Editor:

  • USE mydatabase
  • CREATE DATABASE sampledb
  • SHOW DATABASES
  • SHOW COLLECTIONS
  • SHOW USERS
  • SHOW PROFILES

Insert example:

USE sampledb;

db.getCollection('employees').insert({
    firstName: 'John',
    lastName: 'Smith',
    age: 28,
    hobbies: [
        { name: 'Swimming' },
        { name: 'Jogging' }
    ]
});

Map-Reduce Jobs

The Query Editor can execute map-reduce jobs:

local.words.insertOne({word: 'sample'});
local.words.insertOne({word: 'day'});
local.words.insertOne({word: 'plane'});

var m = function map() {
    emit(this.word, {count: 1})
}
var r = function reduce(key, values) {
    var count = 0
    for (var i = 0; i < values.length; i++)
        count += values[i].count
    return {count: count}
}
local.words.mapReduce(m, r);