Answers for "List mongo databases"

C#
9

mongodb show database command linux

show databases
show dbs
Posted by: Guest on May-29-2020
4

mongodb show database command linux

show collections
show tables
db.getCollectionNames()
Posted by: Guest on May-29-2020
0

List mongo databases

using System;
using MongoDB.Driver;
using MongoDB.Bson;

namespace SimpleEx
{
    class Program
    {
        static void Main(string[] args)
        {
            var dbClient = new MongoClient("mongodb://127.0.0.1:27017");
            var dbList = dbClient.ListDatabases().ToList();

            Console.WriteLine("The list of databases are:");

            foreach (var item in dbList)
            {
                Console.WriteLine(item);
            }
        }
    }
}
Posted by: Guest on October-13-2021

C# Answers by Framework

Browse Popular Code Answers by Language