Skip to content

Setup and Installation

RezaNajafian edited this page Dec 8, 2025 · 1 revision

This page explains how to add MongoHelper to your project and create a basic MongoHelper instance.

1. Add Dependencies

MongoHelper depends on the official MongoDB Java driver. Add both to your build.

Maven Example

<dependencies>
    <!-- MongoDB Java driver -->
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongodb-driver-sync</artifactId>
        <version>VERSION_HERE</version>
    </dependency>

    <!-- MongoHelper -->
    <dependency>
        <groupId>net.clydo</groupId>
        <artifactId>mongohelper</artifactId>
        <version>VERSION_HERE</version>
    </dependency>
</dependencies>

Gradle Example (Kotlin DSL)

dependencies {
    implementation("org.mongodb:mongodb-driver-sync:VERSION_HERE")
    implementation("net.clydo:mongohelper:VERSION_HERE")
}

Replace VERSION_HERE with the actual versions you publish or use.

2. Create a MongoClient

Use the official MongoDB driver to create a MongoClient.

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;

MongoClient client = MongoClients.create("mongodb://localhost:27017");

You can customize the connection string and settings according to your environment.

3. Create a MongoHelper Instance

MongoHelper is your main API surface. Create it using the static create method:

import net.clydo.mongo.MongoHelper;

// ...

MongoHelper mongoHelper = MongoHelper.create(client);

Internally, this constructs a MongoHelperImpl which extends SchematicRegistry and is responsible for:

  • Holding the MongoClient
  • Managing registered schematics
  • Building metadata and indexes
  • Creating and caching OperationsGroup instances

From this point, you can register schematics and start performing operations on your models.

Clone this wiki locally