Skip to content

Overview

RezaNajafian edited this page Dec 8, 2025 · 1 revision

Overview

MongoHelper is a helper library built on top of the official MongoDB Java driver. It provides a simple, metadata-driven way to:

  • Describe your data model using an OrmSchematic
  • Automatically create collections and indexes based on metadata
  • Access grouped CRUD operations through OperationsGroup

Instead of working directly with MongoCollection everywhere, you:

  1. Define an OrmSchematic that lists your models, value types, and enums.
  2. Register that schematic in a MongoHelper instance.
  3. Retrieve an OperationsGroup for each model to perform operations.

This leads to cleaner code, a single place to configure your MongoDB schema, and reusable metadata for indexes and codecs.

Main Building Blocks

  • MongoHelper: The main entry point. Created from a MongoClient. You use it to register schematics and get OperationsGroup instances.
  • OrmSchematic: Describes which database to use and which model/type/enum classes belong to that schema. Optionally customizes codec registries.
  • SchematicRegistry (internal): Manages schematics, builds metadata, and creates collections and indexes.
  • OperationsGroup<M>: Groups all operations for a given model class M (count, create, delete, find, update, upsert).

MongoHelper does not replace the MongoDB driver. It builds on top of it and manages metadata, codec registries, and per-model operations so that your application code can be simpler and more consistent.

Clone this wiki locally