Skip to content

Instantly share code, notes, and snippets.

@ss23
Created August 19, 2018 21:27
Show Gist options
  • Select an option

  • Save ss23/8d601d3946dee471b59ecb8702d0e740 to your computer and use it in GitHub Desktop.

Select an option

Save ss23/8d601d3946dee471b59ecb8702d0e740 to your computer and use it in GitHub Desktop.
err := c.Pipe([]bson.M{
{"$sort": bson.M{
"timestamp": -1,
}},
{"$group": bson.M{
"_id": "$ip",
"openports": bson.M{"$first": "$openports"},
}},
{"$match": bson.M{
"openports.0": bson.M{"$exists": true},
}},
{"$addFields": bson.M{
"openportscount": bson.M{"$count": "$openports"},
}},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment