schema

package
v0.0.6-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2026 License: MIT, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIndexCollectionRequired = errors.New("index collection is required")
	ErrIndexNameRequired       = errors.New("index name is required")
	ErrIndexMustDefineKey      = errors.New("index must define at least one key")
	ErrIndexAlreadyRegistered  = errors.New("index already registered")
)
View Source
var (
	ErrCollectionNameRequired = errors.New("collection name is required")
)

Functions

func Collections

func Collections() []string

func ImportIndexesFromMongo

func ImportIndexesFromMongo(ctx context.Context, db *mongo.Database) (int, error)

func IndexesByCollection

func IndexesByCollection() map[string][]IndexSpec

IndexesByCollection groups specs by collection name.

func MustRegister

func MustRegister(specs ...IndexSpec)

MustRegister adds specs and panics if any registration fails.

func MustRegisterCollections

func MustRegisterCollections(names ...string)

func MustRegisterValidator

func MustRegisterValidator(specs ...ValidatorSpec)

func Register

func Register(spec IndexSpec) error

func RegisterCollection

func RegisterCollection(name string) error

func RegisterValidator

func RegisterValidator(spec ValidatorSpec) error

Types

type IndexSpec

type IndexSpec struct {
	Collection          string
	Name                string
	Keys                bson.D
	Unique              bool
	Sparse              bool
	PartialFilter       bson.D
	ExpireAfterSeconds  *int32
	AdditionalStatement string
}

func Indexes

func Indexes() []IndexSpec

func (IndexSpec) KeyString

func (s IndexSpec) KeyString() string

KeyString renders the index keys in deterministic order.

func (IndexSpec) PartialFilterString

func (s IndexSpec) PartialFilterString() string

PartialFilterString renders the partial filter expression, if any.

type ValidatorSpec

type ValidatorSpec struct {
	Collection  string
	Description string
	Schema      bson.M
	Level       string // off, moderate, strict
}

func Validators

func Validators() []ValidatorSpec

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL