keel/persistence/mongo
2023-09-11 10:37:18 +02:00
..
collection.go feat: add nats readmer 2023-09-11 10:37:18 +02:00
entity.go feat: add mongo persistance 2021-10-01 16:19:13 +02:00
persistor.go fix: change otel mongo enabled env var 2022-07-05 16:20:26 +02:00
readme.go feat: add nats readmer 2023-09-11 10:37:18 +02:00
utils.go fix: use background context 2023-02-23 09:40:18 +01: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()
}