The collection created by mongodb cannot be deleted and the data in the collection cannot be obtained. Please ask for help.

  mongodb, question

I created a category in MongoDB Community and added some test data to it. When I called the database query, I found that there was no data to query. At first, I thought I wrote the wrong name of the category, but the result was not.

When I used the command line to retrieve the database and check the collection name, I found that there was such a collection.


There is also data in the collection.

But when i query was assembled, no data was found.


As a result, I wanted to add a piece of data to this category set to see the situation. As a result, the newly added data was not added to the category set but a new set with the same name was created and the new data just now was added to the new set.


Then, when the query was made again, only the contents of the new set were found.

Finally, when I wanted to delete both sets, I found that the old category set could not be deleted.

The above is some basic information of the problem, so the last thing I want to ask is

Why can’t the collection I created in MongoDB Community get the data and delete it?

What version of MongoDB is it first?
Generally, this kind of problem comes from different codes or special characters that cannot be displayed in the collection name.
First look at the results of this implementation:db.getCollectionNames(), will return you an array and count where your collection appears (note that the array subscript starts at 0).
Then try:db[db.getCollectionNames()[n]].drop();Where n is the position you just counted.