To get started with RxGORM for MongoDB in a Grails application simply add the following dependency to your build.gradle file:
build.gradleimplementation "org.grails.plugins:rx-mongodb:{version}"If you are not developing a Grails application then define the following dependency in your build.gradle or pom.xml:
build.gradleimplementation "org.grails:grails-datastore-gorm-rx-mongodb:{version}"With that done you will need to place the following logic in the bootstrap path of your application:
import org.grails.datastore.rx.mongodb.*
import com.mongodb.rx.client.MongoClient
...
MongoClient mongoClient = ... // create the MongoClient
new RxMongoDatastoreClient(
mongoClient, // (1)
"myDatabase", // (2)
MyClass // (3)
)-
The
MongoClientinstance -
The name of the default database to save objects to
-
One or many classes that implement RxEntity
The org.grails.datastore.rx.mongodb.RxMongoDatastoreClient class is required to initialize RxGORM for MongoDB.