How can we retrieve the databases in JavaScript array in mongodb?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhishek YadavRank #217 · 11.3K reputationPosted Oct 19, 2022, 9:29 PM EDT
> db.getMongo().getDBNames() [ "test", "admin", "local" ] > db.getMongo().getDBNames function () { return this.getDBs().databases.map(function (z) {return z.name;}); }