Skip to content
Monghoul

Generate realistic test data

Fill a collection with documents that keep the shape, the types and the unique constraints of the real thing.

Checked against v1.11.0 Updated
The data generation dialog mapping fields to Faker categories, with a preview
Test data · Fields mapped to Faker categories, previewed before writing

Start from a real collection

Do not build the schema by hand. Seed the generator from a collection you already have, and it keeps each field’s type: array element types, Long, Int32, Double, Decimal128, and fields that are only sometimes null.

  1. Right-click a collection and choose to generate data.
  2. Seed the tree from the sampled collection.
  3. Adjust the fields you care about.
  4. Preview a sample document, then generate.

The two things that usually break generated data

A unique index. A field covered by one is generated so no two documents repeat a value, and a second run continues the series rather than replaying the first. So you can top up a collection without a duplicate key error.

GeoJSON. A coordinates field is generated as the shape its own geometry needs: a pair for a Point, two for a LineString, a closed ring for a Polygon. A 2dsphere index will accept the result.

Making it look real rather than random

  • Faker, across 17 named categories, for names, emails, addresses, companies, commerce, finance, dates, vehicles and more. Each generator shows an example value.
  • List, to pick at random from a set you define. This is how you get a status field with the five values your app actually uses.
  • Range, for a numeric minimum and maximum with a decimal place count.
  • Literal, for a value that has to be the same on every document.
  • Null probability per field, from 0 to 100 percent, because real collections are sparse and code that has never seen a missing field will meet one in production.

Limits

Up to 100,000 documents per run on Pro, and 500 on Free. Generation runs in the background with progress, so a large run does not lock the window.

Next