Reputation: 1
I am trying to migrate from Couchbase Java-sdk 2.7.23 to 3.x. Can't resolve flatMap with the below in Scala.
Unable to resolve flatMap() while fetching multiple documents from Couchbase
val reactiveCollection = bucket.scope("default").collection("default").reactive()
val docsToFetch = util.Arrays.asList("doc1", "doc2").toList
val fetchedResult: List[GetResult] = Flux.fromIterable(docsToFetch)
.flatMap(key => reactiveCollection.get(key))
.collectList()
.block()
Upvotes: 0
Views: 64
Reputation: 68
There is nothing wrong with the flatMap function. Only thing you need to do is convert java list to scala list as below
val reactiveCollection = bucket.scope("default").collection("default").reactive
val docsToFetch: util.List[String] = java.util.Arrays.asList("doc1", "doc2")
import scala.collection.JavaConverters._
val fetchedResult: List[GetResult] = Flux.fromIterable(docsToFetch)
.flatMap { key => reactiveCollection.get(key) }
.collectList()
.block().asScala.toList
Upvotes: 0