Created
September 18, 2014 13:32
-
-
Save yujikiriki/106c8c6c5e18100ae876 to your computer and use it in GitHub Desktop.
ReactiveMongo aggregation pipeline example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def query( ): Future[ List[ JsObject ] ] = { | |
val group: Group = Group( BSONString( "$order.year" ) )( ("total", SumField( "value" )) ) | |
val pipeline: Seq[ PipelineOperator ] = Seq( group ) | |
val command: Future[ Stream[ BSONDocument ] ] = db.command( Aggregate( "opportunities", pipeline ) ) | |
command map { | |
c => | |
c.toList map { | |
d => | |
toJSON( d ).asInstanceOf[ JsObject ] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm interesting by your example but where come from Aggregate and toJSON ?
Thanks for your reply !