I need to return array of string with mongodb aggregation. I did the following:
db.users.aggregate([{$group: {_id:"$emails.address"}}])
It return:
{ "_id" : [ "[email protected]" ] }
{ "_id" : [ "[email protected]" ] }
{ "_id" : [ "[email protected]" ] }
Is there a way to return array of string like this one:
["[email protected]","[email protected]","[email protected]"]
thank You very much anyone who taking your time for helping me..
EDIT
Adding data:
{
"_id" : "ukn9MLo3hRYEpCCty",
"createdAt" : ISODate("2015-10-24T03:52:11.960Z"),
"emails" : [
{
"address" : "[email protected]",
"verified" : false
}
]
}
{
"_id" : "5SXRXraariyhRQACe",
"createdAt" : ISODate("2015-10-24T03:52:12.093Z"),
"emails" : [
{
"address" : "[email protected]",
"verified" : false
}
]
}
{
"_id" : "WMHWxeymY4ATWLXjz",
"createdAt" : ISODate("2015-10-24T03:52:12.237Z"),
"emails" : [
{
"address" : "[email protected]",
"verified" : false
}
]
}