Skip to content

Instantly share code, notes, and snippets.

@scaleupcto
Created September 4, 2012 19:12
Show Gist options
  • Save scaleupcto/3625201 to your computer and use it in GitHub Desktop.
Save scaleupcto/3625201 to your computer and use it in GitHub Desktop.
db.raw_data.aggregate(
{ $match:{"_id.s":"1234-5678"}},
{ $project :
{
s: "$_id.s",
res: { d: "$_id.d", v: "$v"},
dt: 1
}
},
{
$unwind: "$dt"
},
{ $group :
{ _id : "$dt",
res: {$addToSet: "$res"}
}
},
{ $project :
{
_id : 0,
type: "$_id",
res: 1,
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment