Error when trying to compact a Mongo collection


I am getting the following error when compacting a collection:

Any ideas what the issue is?


Welcome back to the MongoDB Community Forums @Ian_Hannah !

“errmsg” : “collection name has invalid type object”

The issue is that you are providing an object (db.childdata) for the collection name to compact rather than the expected string value.

Something like the following should work:

db.runCommand({compact: "childdata"})

Note: code and log snippets are better as inline text. Images can be difficult to read (for example, this one seems to be oddly resized) and do not allow copying & pasting commands to reproduce issues.


Thank you so much! That did the trick

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.