0

I have some binary data inside a mongodb collection. I would like to clear a little bit the too heavy data. How can I sort the top 10 binary data (biggest size on disk)? Thanks

1 Answer 1

1

Use this:

db.collection.aggregate([
  { $set: { binSize: { $bsonSize: "$binary_data" } } },
  { $sort: { binSize: -1 } },
  { $limit: 10 }
])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.