score:4
reactivemongo is way too clever with a lot of these inner case classes, etc., and every time i've had to use it i've run into weird problems like this. you can force it to compile by providing a type annotation that fixes the scope of the existential:
scala> type famresult =
| c.batchcommands.findandmodifycommand.findandmodifyresult forsome {
| val c: bsoncollection
| }
defined type alias famresult
scala> def remove =
| testcoll.flatmap[famresult](_.findandremove(bsondocument("atomicnumber" -> 26)))
remove: scala.concurrent.future[famresult]
unless you don't care about the removal command results, though, this probably isn't ideal. a better approach is to map into the future[<blah blah blah>.findandmodifyresult]
inside the flatmap
so that you end up with a more useful type:
scala> def remove = testcoll.flatmap(
| _.findandremove(bsondocument("atomicnumber" -> 26)).map(_.value)
| )
remove: scala.concurrent.future[option[reactivemongo.bson.bsondocument]]
you could also just .map(_ => ())
if you actually don't care about the result, .map(_.result[element])
if you want the result decoded, etc.
Source: stackoverflow.com
Related Query
- BSONCollection.findAndRemove() cannot be called using flatmap
- How to declare scala method so that it can be called from Java using varargs style
- SPARK dataframe error: cannot be cast to scala.Function2 while using a UDF to split strings in column
- How to assert that mocked method is never called using ScalaTest and ScalaMock?
- How to merge two Option[String] variables into one when using flatMap in Scala?
- Scala: How do I calculate the variance of a Seq[Double] using flatMap and Options?
- Cannot set a java annotation member called type in scala?
- Methods ready and result of Future in Scala cannot be called directly
- Cannot resolve symbols (foreach, list,...) using Slick-play
- Verify that a method was called using Mockito without specifying arguments
- value flatMap is not a member of type parameter F[Long] when using cats.effect
- When using shapeless.Generic, how to avoid the error 'super constructor cannot be passed a self reference unless parameter is declared by-name'?
- Attach column names to elements with Spark and Scala using FlatMap
- Cannot instantiate user function in scala using flink
- Cannot select the scala sdk when using Intellij after installed the scala plugin
- How to execute map, filter, flatMap using multiple threads in RxScala/Java?
- Why can I not flatMap a List[Option] using underscore?
- Converting List[Option[A]] to Option[List[A]] using Map instead of FlatMap
- Clarification on why I cannot override a method using a generic class parameter by a subtype of it
- using Try in flatMap
- Cannot deserialize a generic collection using spray-json
- explode a row of spark dataset into several rows with added column using flatmap
- Cannot define a property called `wait` in Scala case class
- A typical scenario of using flatMap in State Monad?
- Cannot created object walking though JSON string using Circe JSON parser
- Cannot mock WSRequest.post() using scalamock
- IntelliJ 11 cannot resolve Play/Scala models without using root package in import statements
- Cannot parse Date using SimpleDateFormat in java/scala
- Cannot insert values from form using Play for Scala and Anorm
- Scala: list to set using flatMap
More Query from same tag
- Gradle separate test classpath dependencies for scala and java tests
- Scala @tailrec with fold
- how to set main class in SBT 0.13 project
- Can someone explain this line of Scala code to me?
- groupByKey vs. aggregateByKey - where exactly does the difference come from?
- Simple Akka mailbox configuration to discard overflowing messages
- In Scala, how do I initialise abstract vals in traits?
- Converting case class to another recursively structural identical case class
- package in sparklauncher in Apache Spark?
- Can't assign returned java.util.ArrayList to scala.collection.mutable.ArrayBuffer. Why?
- Parsing Nested JSON Data using SCALA
- How to code this validation logic in Scala?
- How to transform a flat table dataframe into a dataframe with nested arrays
- EmrOptimizedSparkSqlParquetOutputCommitter not found
- Implement fold with for-comprehension
- Scala Reflection - Loading or finding classes based on trait
- What can be recovered by Akka Future recover?
- Gatling stomp pub/sub load testing
- Swagger does not working well with Play Framework 2
- In Scala is it possible to retrieve the `val` referenced by a singleton type?
- How to delete useless registers generated by Chisel verilog backend?
- Controller issue when creating new Play application with Intellij 15
- Casbah - check if string is parseable as ObjectId
- Compiling Java annotations with sbt
- How do I rollback a session in ScalaQuery?
- How to get pretty output from specs+scalacheck with maven?
- Calculate mathematical operation stored in String using regex in Scala
- correct usage of scala map
- scala: pimp my library with overloads
- How to tune save operation with partitionBy