I have a collection named "myplace" It has the following fileds place_name, city, latitude, longitude.
Doc format
{
"_id" : ObjectId("544a2147785b707b340ed6c7"),
"latitude" : 12.36547,
"longitude" : 1.235689,
"place_name" : "some_place",
"city" : "City1"
}
{
"_id" : ObjectId("544a2147785b707b340ed6c7"),
"latitude" : 12.36547,
"longitude" : 1.235689,
"place_name" : "some_place",
"city" : "City3"
}
{
"_id" : ObjectId("544a2147785b707b340ed6c7"),
"latitude" : 12.36547,
"longitude" : 1.235689,
"place_name" : "some_place",
"city" : "City1"
}
{
"_id" : ObjectId("544a2147785b707b340ed6c7"),
"latitude" : 12.36547,
"longitude" : 1.235689,
"place_name" : "some_place",
"city" : "City2"
}
{
"_id" : ObjectId("544a2147785b707b340ed6c7"),
"latitude" : 12.36547,
"longitude" : 1.235689,
"place_name" : "some_place",
"city" : "City2"
}
How can I group the data with same city? Meaning I need array of json result first array should contain all the data which having city1 second array conatins all the data which having city2 and so on