aggregate and store in mongodb