Hello, I got this error MongoServerError[AtlasError]: CMD_NOT_ALLOWED: compact when trying to compact a collection from mongosh. I connect using a user with atlasAdmin @admin role and with an additional custom role that I created specifically for the compact operation on that collection. The database version is 8. The compact command that I use is
db.runCommand(
{
compact: "(my collection name)",
force:true
}
)
I got this error only if I connect to a database hosted on Atlas but it works when I connect to a local database.
The user has been created from the Atlas UI using the button “Add New Database User” and with this user I can read and write all the collections, but the compact command is not allowed.