From Mongodb client, we can use db.Collection.stats() to get status of collections, such as:
+ Number of records (count)
+ Size on disk (storageSize)
This will work:
CommandResult resultSet = db.getCollection("emp").getStats();
System.out.println(resultSet);
you will get all the details of status.ouput:
{ "ns" : "test.emp" , "count" : 2 , "size" : 96 , "avgObjSize" : 48 , "numExtents" : 1 , "storageSize" : 8192 , "lastExtentSize" : 8192.0 , "paddingFactor" : 1.0 , "paddingFactorNote" : "paddingFactor is unused and unmaintained in 3.0. It remains hard coded to 1.0 for compatibility only." , "userFlags" : 1 , "capped" : false , "nindexes" : 1 , "indexDetails" : { } , "totalIndexSize" : 8176 , "indexSizes" : { "_id_" : 8176} , "ok" : 1.0}