MongoDb Features

DbSchema can connect to MongoDb and reverse engineer the logical schema by reading data samples from the database. This is done by the DbSchema JDBC driver, which is open source ( see https://dbschema.com/mongodb-tool.html for details ).

MongoDB Diagrams

DbSchema can connect to MongoDB and reverse engineer a Model from the database structure. This is done by introspecting random documents from each collection. This DbSchema model will be saved to file.

MongoDB Diagrams

Visual Query Editor

DbSchema features a visual query builder for MongoDB. This can make use of filters, projections, aggregation. The generated queries are shown on the right side of the query builder. The queries are in the native MongoDB language.

MongoDB Query Builder

HTML Documentation

DbSchema can export the MongoDB diagrams as interactive HTML5 or PDF documentation files. The collection and fields comments can be read as mouse-over tooltips.

HTML Documentation

Data Generator

Developers and testers may need to test the database performance by filling collections with random data documents. This can be done using the Data Generator, which may use pre-configured patterns or reverse regular expressions.

Data Generator

Compare Virtual Schema

The DbSchema model contains its own local image of the database structure. This can be compared with other MongoDB databases or other DbSchema model files.

Compare MongoDB database structure

Query Editor

In the Query Editor you can write native MongoDb queries. Please notice you can use the keyword 'db' for referring the current database you are connected to, or directly the database name if you need to simultaneously access multiple databases.

use sampleDb
db.employees.find()
or
sampleDb.employees.find()
or
sampledb.getCollection('employees').find();

Further commands which are available in in the Query Editor are:

A sample insert into the database :

  USE sampledb;

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

Map-Reduce Jobs

From the Query Editor you can execute map-reduce jobs as in this sample:
local.words.insertOne({word: 'sample'});
local.words.insertOne({word: 'day'});
local.words.insertOne({word: 'plane'});

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

or

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