Fedor March
Fedor March

Reputation: 87

db.listCollections() does not work in mongodb6.0.3

I used mongodb version < 4. Now I needed to install mongodb on ubuntu 22, the easiest way was to install version 6.0.3 But now some of the functionality does not work, for example

db.listCollections() 

-There were no problems, but after upgrading to mongodb6.0.3 - it does not work. I read that it is advised to use

db.getCollectionNames()

Are these functions interchangeable? Is there no difference between them? And is it possible to make db.listCollections() work in version 6.0.3?

I read here that many functions are already outdated in version 5

Upvotes: 0

Views: 45

Answers (1)

Joe
Joe

Reputation: 28336

db.listCollections() was a convenience wrapper in the legacy shell.

To get the same behavior in mongosh, use the listCollections database command, like

db.runCommand("listCollections")

Upvotes: 1

Related Questions