pymongo - How to Change output format when using group in aggregation mongodb -


i need change out put format of following mongodb query.

query

 db.response.aggregate([{        "$match": {          "$and": [{            "job_details.owner_id" : 482,          }, {            "job_details.owner_type" : 'searches',          }],        },    },     {       "$group": {          "_id": "$candidate_sublocation_name_string",          "count": {            "$sum": 1,          },       },    }]) 

actual out put

{ "_id" : "central delhi ", "count" : 1 } { "_id" : "adyar ", "count" : 1 } { "_id" : "bommanahalli", "count" : 2 } { "_id" : "dlf phase 3 ", "count" : 2 } { "_id" : "aai colony", "count" : 1 } 

needed out put

 { "central delhi" : 1 }     { "adyar" : 1 }     { "bommanahalli" : 2 }     { "dlf phase 3 ": 2 }     { "aai colony": 1 } 

is possible change out put format this..?


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -