GitXplorerGitXplorer
c

reactor-mongodb

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
66c5d54c889cb63f5b249afad41cc72f86fd218e

Updated to 1.7.1

ccedrickring committed 7 years ago
Unverified
358bb2e7a6ebb8b89e152980460273836c242831

Moved lambda out of arguments

ccedrickring committed 7 years ago
Verified
5a267363b109bb8b0c70f6df9ddd9906d1b3fe9f

Update README.md

ccedrickring committed 7 years ago
Unverified
76e53dd7813d4d7f9a7cf269cc819b8595b47e91

Fix README mistake

ccedrickring committed 7 years ago
Unverified
a329592451f5c0f9aba2fca530b4c744b7f90347

Added sonatype deployment

ccedrickring committed 7 years ago
Unverified
fc05286063e0ddd33b71c514e1373f2d5464d05d

Removed fully qualified paths

ccedrickring committed 7 years ago

README

The README file for this repository.

Reactor MongoDB

A wrapper built upon the mongodb-async api with Reactor (http://projectreactor.io/) written in Kotlin, but fully compatible with Java (due to @JvmOverloads).

Dependencies

  • org.mongodb::mongodb-driver-async
  • io.projectreactor::reactor-core

Maven

<dependency>
    <groupId>com.github.cedrickring</groupId>
    <artifactId>reactor-mongodb</artifactId>
    <version>1.7</version>
</dependency>

Example Usage

Java:

ReactiveMongoClient client = ReactiveMongoClient.fromURI("mongodb://<URL>");
ReactiveDatabase database = client.getDatabase("<name>"); //get a reactive database

//To get a collection, use
ReactiveCollection<Document> collection = database.getCollection("<name>");

//or with a specific type
ReactiveCollection<MyType> collection = database.getCollection("<name>");

//you can also use factory methods known from MongoCollection
collection.withWriteConcern(...).withCodecRegistry(...);

//To find documents in a collection, use
Flux<Document> documents = collection.find(Filters.eq("name", "John"));

//then subscribe to it
documents.subscribe(document -> document.getString("name"));

//or use other functions from Flux
documents.map(document -> document.getString("name")).subscribe(...);

Kotlin:

val client = ReactiveMongoClient.fromURI("mongodb://<URL>")
val database = client.getDatabase("name")

//in Kotlin we have some useful methods to avoid usage of T::class.java
val collection = database.collection<Type>("<name>")

//find documents of a specific type
val find: Flux<Type> = collection.findWithType<Type>(Filters.eq("my", "filter"))

//or without a specified type
val find: Flux<Document> = collection.find(...)

//then just subscribe to it
find.subscribe { println(it) }