dropIndexes syntax at documentation


I’m new to MongoDB and I had some problems with dropIndexes method in some collections I’m working with.
Seems like the documentation is misleading, or maybe a version problem with the mongoDB I’m using. I just wanted to point out - I don’t know if this is the best place for it, but let’s go:
In this page, they say the correct syntax is:

db.<collection>.dropIndexes("<index1>", "<index2>", "<index3>")

But this one is slighter different, an array:

db.collection.dropIndexes( [ "a_1_b_1", "a_1", "a_1__id_-1" ] )

Only the second one worked for me.

Yeah it looks like a typo, the first doc says you need an array:

but the example code doesn’t have an array around the indexes.

Thanks for raising this one guys. I’ll raise this with the team and update this post when there is an updated example.


1 Like

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