Skip to content

Instantly share code, notes, and snippets.

@marcusdb
Created June 19, 2016 20:11
Show Gist options
  • Select an option

  • Save marcusdb/1f3eccb8f0ca11176e6db38c5b3f4dd9 to your computer and use it in GitHub Desktop.

Select an option

Save marcusdb/1f3eccb8f0ca11176e6db38c5b3f4dd9 to your computer and use it in GitHub Desktop.
Find large arrays in documents
db.collection.aggregate( [
{ $unwind : "$l" },
{ $group : { _id : "$_id", len : { $sum : 1 } } },
{ $sort : { len : -1 } },
{ $limit : 25 }
] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment