Get MongoDB Databases in a Javascript Array

282 views
Skip to first unread message

jprichardson

unread,
Oct 26, 2010, 2:02:38 PM10/26/10
to mongodb-user
I know that in the MongoDB terminal, I can run "show dbs" to see the
available databases. I want to get them programmatically so that I can
iterate over them and delete some based upon a regular expression.

I have tried db.runCommand("show dbs") but that doesn't work.

Thanks in advance.

Robert Stam

unread,
Oct 26, 2010, 2:17:31 PM10/26/10
to mongodb-user
You can use:

> use admin
switched to db admin
> db.runCommand({listDatabases:1})

Scott Hernandez

unread,
Oct 26, 2010, 2:19:26 PM10/26/10
to mongod...@googlegroups.com
db._adminCommand("listDatabases")

all commands are listed here:
http://www.mongodb.org/display/DOCS/List+of+Database+Commands

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages