func GetDatabaseStatList(client *mongo.Client) *DatabaseStatList {
	dbStatList := &DatabaseStatList{}
	dbNames, err := client.ListDatabaseNames(context.TODO(), bson.M{})
	if err != nil {
		log.Errorf("Failed to get database names, %v", err)
		return nil
	}
	for _, db := range dbNames {
		dbStatus := DatabaseStatus{}
		err := client.Database(db).RunCommand(context.TODO(), bson.D{{"dbStats", 1}, {"scale", 1}}).Decode(&dbStatus)
		if err != nil {
			log.Errorf("Failed to get database status: %s.", err)
			return nil
		}
		dbStatList.Members = append(dbStatList.Members, dbStatus)
	}

	return dbStatList
}
// GetDatabaseStatList returns stats for all databases
GetDatabaseStatList returns stats for all databases
// GetDatabaseStatList returns stats for all databases
func GetDatabaseStatList(client *mongo.Client) *DatabaseStatList {
	dbStatList := &DatabaseStatList{}
	dbNames, err := client.ListDatabaseNames(context.TODO(), bson.M{})
	if err != nil {
		log.Errorf("Failed to get database names, %v", err)
		return nil
	}
	for _, db := range dbNames {
		dbStatus := DatabaseStatus{}
		err := client.Database(db).RunCommand(context.TODO(), bson.D{{"dbStats", 1}, {"scale", 1}}).Decode(&dbStatus)
		if err != nil {
			log.Errorf("Failed to get database status: %s.", err)
			return nil
		}
		dbStatList.Members = append(dbStatList.Members, dbStatus)
	}
	return dbStatList
}
func GetDatabaseStatList ( client * mongo . Client ) * DatabaseStatList { dbStatList := & DatabaseStatList { } dbNames , err := client . ListDatabaseNames ( context . TODO ( ) , bson . M { } ) if err != nil { log . Errorf ( " " , err ) return nil } for _ , db := range dbNames { dbStatus := DatabaseStatus { } err := client . Database ( db ) . RunCommand ( context . TODO ( ) , bson . D { { " " , 1 } , { " " , 1 } } ) . Decode ( & dbStatus ) if err != nil { log . Errorf ( " " , err ) return nil } dbStatList . Members = append ( dbStatList . Members , dbStatus ) } return dbStatList }
GetDatabaseStatList returns stats for all databases
GetDatabaseStatList returns stats for all databases