Reputation: 2143
I have data in below format
{
"result" : [
{
"advertiser" : "lordandtaylor"
,
"networks" : [
"Pepperjam"
],
"publishers" : [
"best-price.com",
"allthingswholesale.com"
]
}]
}
Now I want to display this in below format
{"advertiser":"lordandtaylor" , "networks":"1" , "publishers":"2"}
Upvotes: 1
Views: 63
Reputation: 2143
I got the solution
db.link.aggregate([
{
{
$project : { _id: 0, advertiser : "$_id.advertiser", networks : {$size : "$networks"} , advertisers : {$size : "$publishers"} }
}
]);
Upvotes: 1