Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ReactiveMongo aggregation pipeline example
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 ]
}
}
}
@scalastic

This comment has been minimized.

Copy link

@scalastic scalastic commented Jul 6, 2015

I'm interesting by your example but where come from Aggregate and toJSON ?
Thanks for your reply !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment