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

Time:03-21

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

CodePudding user response:

Try this one:

db.collection.aggregate([
   { $set: { size: { $bsonSize: "$$ROOT" } } },
   { $match: { size: { $gt: 15 * 1024 * 1024 } } }
])
  • Related