func (c *Catalog) All() map[Model][]Index {
	all := make(map[Model][]Index, len(c.models))
	for _, model := range c.models {
		all[model] = make([]Index, 0)
		for _, index := range c.indexes[GetMeta(model).PluralName] {
			all[model] = append(all[model], index)
		}
	}
	return all
}
All returns a list of all registered models.
package coal
import (
	"bytes"
	"context"
	"fmt"
	"io/ioutil"
	"os/exec"
	"sort"
	"strings"
	"time"
	"github.com/256dpi/xo"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
)
type Index struct {
	Model  Model
	Fields []string
	Unique bool
	Expiry time.Duration
	Filter bson.D
}
func (i *Index) Compile() mongo.IndexModel {
	var key []string
	for _, f := range i.Fields {
		key = append(key, F(i.Model, f))
	}
	opts := options.Index().SetUnique(i.Unique).SetBackground(true)
	if i.Filter != nil {
		opts.SetPartialFilterExpression(i.Filter)
	}
	if i.Expiry > 0 {
		opts.SetExpireAfterSeconds(int32(i.Expiry / time.Second))
	}
	return mongo.IndexModel{
		Keys:    Sort(key...),
		Options: opts,
	}
}
type Catalog struct {
	models  map[string]Model
	indexes map[string][]Index
}
func NewCatalog(models ...Model) *Catalog {
	c := &Catalog{
		models:  make(map[string]Model),
		indexes: map[string][]Index{},
	}
	c.Add(models...)
	return c
}
func (c *Catalog) Add(models ...Model) {
	for _, model := range models {
		name := GetMeta(model).PluralName
		if c.models[name] != nil {
			panic(fmt.Sprintf(`coal: model with name "%s" already exists in catalog`, name))
		}
		c.models[name] = model
	}
}
func (c *Catalog) Find(pluralName string) Model {
	return c.models[pluralName]
}
func (c *Catalog) FindIndexes(pluralName string) []Index {
	return c.indexes[pluralName]
}
func (c *Catalog) Models() []Model {
	models := make([]Model, 0, len(c.models))
	for _, model := range c.models {
		models = append(models, model)
	}
	return models
}