Watch keynotes and sessions from, our virtual developer conference.

Automating the compact() command via the API

Recently we have cleaned some data from our DB, so we want to reduce storage space.

However, the storage size remains as is. We asked the support team how to Reclaim/reduce disk space in MongoDB and were advised to use the compact command.

We ran the command manually as of now. I was wondering if anyone has a script that utilizes the API to run the command. Here is the advice we got from the support team at MongoDB:

On the topic of automation of any portion of this process, you can decrement the disk size using the Modify A Cluster API endpoint.