title: Official MongoDB Scala Driver, aggregate count sum 1
body: <p>I am using official mongo scala driver: <a href="http://mongodb.github.io/mongo-scala-driver/" rel="nofollow noreferrer">http://mongodb.github.io/mongo-scala-driver/</a>.</p>
  
  <p>I want to do query like:</p>
  
  <pre><code>db.test.aggregate([{"$group" : {_id:{name:"$name",details:"$details.id"}, count:{$sum:1}}}, {$sort:{"count":-1}} ])
  </code></pre>
  
  <p>so in scala code I am doing:</p>
  
  <pre><code>collectionDoc.aggregate(List(
        group(Document("name" -&gt; "$name", "details" -&gt; "$details.id"), Accumulators.sum("count", "1")),
        )).toFuture()
  </code></pre>
  
  <p>but in all results I see:</p>
  
  <pre><code>(count,BsonInt32{value=0}))
  </code></pre>
  
  <p>From mongo driver logs I see that its send:</p>
  
  <pre><code>{
    "aggregate": "test",
    "pipeline": [
      {
        "$group": {
          "_id": {
            "name": "$name",
            "details": "$details.id"
          },
          "count": {
            "$sum": "1"
          }
        }
      }
    ],
    "cursor": {
      "batchSize": 2147483647
    },
    "$db": "my-db",
    "$readPreference": {
      "mode": "primaryPreferred"
    }
  }
  </code></pre>
  
  <p>If I do this query in mongo it counts those records fine..
  Any idea how to solve this ?</p>
  
  <p>Thanks!</p>