Thursday, 19 September 2013

scala Play Salat Aggregate example

scala Play Salat Aggregate example

I am using Scala Play 2.x with MongoDB in backend. I must confess that
Salat has wonderful support for mongo CRUD operations but so far I didn't
find any good example of how I can call mongo aggregate function using
SALAT like $unwind, $match, $group or aggregate pipeline. For example
db.posts.aggregate([
{
$unwind :"$tag"
},
{ $group :
{
_id :"$tags",
count : {$sum :1}
}
},
{
$sort : {$post :-1}
},
{
$limit :1
}
])
Thanks in advance

No comments:

Post a Comment