use parablu001;
var size;
var deviceUUID;
var destCollection;
var storageUtilizedInCloud;
print("deviceName,deviceUUID,calculatedSize,currentStorageUtilized");
db.DEVICE.find().forEach(  function(e) { if(e.destCollection!=undefined){ destCollection=e.destCollection; size=0; currentStorageUtilized=0; db[destCollection].find({"deviceUUID" :e.deviceUUID,"present":true}).forEach(  function(f) { size=size+f.size; }); if(size != 0){ if(e.deviceBackupOverView!=undefined){ currentStorageUtilized=db.DEVICE_BACKUP_OVERVIEW.findOne({"_id":e.deviceBackupOverView.$id},{"_id":0,"storageUtilized":1}).storageUtilized;
db.DEVICE_BACKUP_OVERVIEW.update({"_id":e.deviceBackupOverView.$id},{$set:{"storageUtilized":NumberLong(size)}});
  print(e.deviceName+","+e.deviceUUID+","+size+","+currentStorageUtilized); }else{ print("deviceUUID:"+e.deviceUUID+" deviceBackupOverView is Empty"); } } }else{ print("deviceUUID:"+e.deviceUUID+"destCollection is Empty"); } });

