def myaggregate() = collection.flatMap { coll => import coll.BatchCommands.AggregationFramework._ coll.aggregate(Group(JsString("$state"))("totalPop" -> SumField("population")), List(Match(Json.obj("totalPop" -> Json.obj("$gte" -> 10000000L))))) }
[error] /home/arussel/MotionMath/git/reactivemongo-lock/app/models/A.scala:22: no type parameters for method flatMap: (f: reactivemongo.play.json.collection.JSONCollection => scala.concurrent.Future[S])(implicit executor: scala.concurrent.ExecutionContext)scala.concurrent.Future[S] exist so that it can be applied to arguments (reactivemongo.play.json.collection.JSONCollection => scala.concurrent.Future[coll.BatchCommands.AggregationFramework.AggregationResult] forSome { val coll: reactivemongo.play.json.collection.JSONCollection })[error] --- because ---[error] argument expression's type is not compatible with formal parameter type;[error] found : reactivemongo.play.json.collection.JSONCollection => scala.concurrent.Future[coll.BatchCommands.AggregationFramework.AggregationResult] forSome { val coll: reactivemongo.play.json.collection.JSONCollection }[error] required: reactivemongo.play.json.collection.JSONCollection => scala.concurrent.Future[?S][error] def myaggregate() = collection.flatMap {[error] ^[error] /home/arussel/MotionMath/git/reactivemongo-lock/app/models/A.scala:23: type mismatch;[error] found : reactivemongo.play.json.collection.JSONCollection => scala.concurrent.Future[coll.BatchCommands.AggregationFramework.AggregationResult] forSome { val coll: reactivemongo.play.json.collection.JSONCollection }[error] required: reactivemongo.play.json.collection.JSONCollection => scala.concurrent.Future[S][error] coll =>[error] ^[error] two errors found[error] (compile:compileIncremental) Compilation failed
You could have a look at the doc samples: http://reactivemongo.org/releases/0.11/documentation/advanced-topics/aggregation.html
You should not have coll.BatchCommands.AggregationFramework.AggregationResult in the return type, but the type parsed from that.
You could have a look at the doc samples: http://reactivemongo.org/releases/0.11/documentation/advanced-topics/aggregation.html
--
You received this message because you are subscribed to a topic in the Google Groups "ReactiveMongo - http://reactivemongo.org" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reactivemongo/9Ypw5daJe3Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reactivemong...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Either you return data parsed from there, or Unit (map the Future to {}).
Having AggregationResult in return types of your API, is meaningless. It's an intermediate result, tied to the MongoDB operation.
Either you return data parsed from there, or Unit (map the Future to {}).
def internal(coll: JSONCollection): Future[coll.BatchCommands.AggregationFramework.AggregationResults] = ???
// used where the collection is resolved properly
database.flatMap { db => internal(db.collection[JSONCollection]("foo")) }