keel/persistence/mongo
Kevin Franklin Kim 0426f92f64
fix: parameter
2025-03-07 16:48:49 +01:00
..
collection.go feat: update & fix lints 2024-04-16 09:38:28 +02:00
entity.go feat: add mongo persistance 2021-10-01 16:19:13 +02:00
persistor.go fix: parameter 2025-03-07 16:48:49 +01:00
readme.go feat: add nats readmer 2023-09-11 10:37:18 +02:00
utils.go feat: update & fix lints 2024-04-16 09:38:28 +02:00

package keelmongo

import (
	"strings"

	"github.com/foomo/keel/markdown"
)

var (
	dbs     = map[string][]string{}
	indices = map[string]map[string][]string{}
)

func Readme() string {
	var rows [][]string
	md := &markdown.Markdown{}

	for db, collections := range dbs {
		for _, collection := range collections {
			var i string
			if v, ok := indices[db][collection]; ok {
				i += strings.Join(v, "`, `")
			}
			rows = append(rows, []string{
				markdown.Code(db),
				markdown.Code(collection),
				markdown.Code(i),
			})
		}
	}

	if len(rows) > 0 {
		md.Println("### Mongo")
		md.Println("")
		md.Println("List of all used mongo collections including the configured indices options.")
		md.Println("")
		md.Table([]string{"Database", "Collection", "Indices"}, rows)
		md.Println("")
	}

	return md.String()
}