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.
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.
The diagram provides an at-a-glance view of your entire MongoDB schema, including nested documents and arrays.
The visual query editor lets you build MongoDB queries using the mouse. It supports:
The generated query is shown on the right side of the query editor and can be copied or executed directly.
Add comments to collections and fields by double-clicking them in the diagram. DbSchema can export the schema as:
Use the Data Generator to populate MongoDB collections with test data. Supported patterns include:
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.
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 mydatabaseCREATE DATABASE sampledbSHOW DATABASESSHOW COLLECTIONSSHOW USERSSHOW PROFILESInsert example:
USE sampledb;
db.getCollection('employees').insert({
firstName: 'John',
lastName: 'Smith',
age: 28,
hobbies: [
{ name: 'Swimming' },
{ name: 'Jogging' }
]
});
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);