Reputation: 437
I'm trying to list all the databases while working inside some 'abc' database using javascript. my admin username is 'xyz' and password is 'abc'. But it is displaying an error- error: uncaughtException: Mongo is not defined. can anyone guide me for the same? thanx.
Upvotes: 3
Views: 311
Reputation: 437
Actually the problem was with authentication of db. The mongo I'm using requires admin authentication before querying or trying any command to process data. I inserted code to authenticate db and got access to db.admin() function of mongodb.
By the way thanx to @arcyqwerty and @Amadan for your support.
Upvotes: 2
Reputation: 10685
From the console you can simply run show dbs
If you need the output in a Javascript object, try db.adminCommand('listDatabases')
Upvotes: 4
Reputation: 198314
MongoDB is a serverside technology. JavaScript (unless you're using Node.js, in which case you should have tagged it) is a client-side technology. Might as well shout for someone in Japan to cook you dinner - too far. You would need to ask a server-side component to ask MongoDB for you and pass you the results.
Upvotes: 0