using pipelines to store in mongodb