Skip to content
Advertisement

In MongoDB, using Java how can I query to find documents exceeding 15 MB storage size in a database or collection

In MongoDB, using Java how can I query to find documents which exceeds the 15mb size in database or collection

Advertisement

Answer

Try this one:

db.collection.aggregate([
   { $set: { size: { $bsonSize: "$$ROOT" } } },
   { $match: { size: { $gt: 15 * 1024 * 1024 } } }
])
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement