Size of data in MongoDB prevoius Month

Dear Team,

I would like to know In MongoDB how to check data size from Current month to Previous Month how much increased

Any MongoDB commands and shell script ?

Hi there! Perhaps one option might be to create a query to get the results of last month and calculate its size using the following code and the repeat the same for the new month.

var cursor = db.collection.find(...); //Add your query here.
var size = 0;
cursor.forEach(
    function(doc){
        size += Object.bsonsize(doc)
    }
);
print(size);

Source: mongodb - Get the size of all the documents in a query - Stack Overflow