Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cedrickring/reactor-mongodb
A wrapper built upon the mongodb-async api with Reactor (http://projectreactor.io/)
https://github.com/cedrickring/reactor-mongodb
Last synced: 23 days ago
JSON representation
A wrapper built upon the mongodb-async api with Reactor (http://projectreactor.io/)
- Host: GitHub
- URL: https://github.com/cedrickring/reactor-mongodb
- Owner: cedrickring
- License: apache-2.0
- Created: 2018-06-02T09:36:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-09T18:58:33.000Z (over 6 years ago)
- Last Synced: 2024-10-26T17:52:58.008Z (2 months ago)
- Language: Kotlin
- Homepage:
- Size: 26.4 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```xml
com.github.cedrickring
reactor-mongodb
1.7```
## Example Usage
Java:
```java
ReactiveMongoClient client = ReactiveMongoClient.fromURI("mongodb://");
ReactiveDatabase database = client.getDatabase(""); //get a reactive database//To get a collection, use
ReactiveCollection collection = database.getCollection("");//or with a specific type
ReactiveCollection collection = database.getCollection("");//you can also use factory methods known from MongoCollection
collection.withWriteConcern(...).withCodecRegistry(...);//To find documents in a collection, use
Flux 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:
```kotlin
val client = ReactiveMongoClient.fromURI("mongodb://")
val database = client.getDatabase("name")//in Kotlin we have some useful methods to avoid usage of T::class.java
val collection = database.collection("")//find documents of a specific type
val find: Flux = collection.findWithType(Filters.eq("my", "filter"))//or without a specified type
val find: Flux = collection.find(...)//then just subscribe to it
find.subscribe { println(it) }
```