Documentation ¶
Index ¶
- Constants
- type SeedCollectionData
- type SeedComponent
- func (m *SeedComponent) AttachEnvironment(_ context.Context, _ *envite.Environment, writer *envite.Writer) error
- func (m *SeedComponent) Cleanup(context.Context) error
- func (m *SeedComponent) Config() any
- func (m *SeedComponent) Prepare(context.Context) error
- func (m *SeedComponent) Start(ctx context.Context) error
- func (m *SeedComponent) Status(context.Context) (envite.ComponentStatus, error)
- func (m *SeedComponent) Stop(context.Context) error
- func (m *SeedComponent) Type() string
- type SeedConfig
Constants ¶
View Source
const ComponentType = "mongo seed"
ComponentType represents the type of the MongoDB seed component.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SeedCollectionData ¶
type SeedCollectionData struct { // DB - the name of the target mongo DB DB string `json:"db,omitempty"` // Collection - the name of the target mongo collection Collection string `json:"collection,omitempty"` // Documents - a list of documents to insert using the mongo InsertMany function: // https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection.InsertMany Documents []any `json:"documents,omitempty"` }
SeedCollectionData represents data for a MongoDB collection.
type SeedComponent ¶
type SeedComponent struct {
// contains filtered or unexported fields
}
SeedComponent is a component for seeding MongoDB with data.
func NewSeedComponent ¶
func NewSeedComponent(config SeedConfig) *SeedComponent
NewSeedComponent creates a new SeedComponent instance.
func (*SeedComponent) AttachEnvironment ¶
func (m *SeedComponent) AttachEnvironment(_ context.Context, _ *envite.Environment, writer *envite.Writer) error
func (*SeedComponent) Config ¶
func (m *SeedComponent) Config() any
func (*SeedComponent) Status ¶
func (m *SeedComponent) Status(context.Context) (envite.ComponentStatus, error)
func (*SeedComponent) Type ¶
func (m *SeedComponent) Type() string
type SeedConfig ¶
type SeedConfig struct { // URI - a valid MongoDB URI to connect to URI string `json:"uri,omitempty"` // ClientProvider - can be used as an alternative to URI, provides a mongo client to use. // available only via code, not available in config files. // if both ClientProvider and URI are provided, ClientProvider is used. ClientProvider func() (*mongo.Client, error) `json:"-"` // Data - a list of objects, each represents a single mongo collection and its data Data []*SeedCollectionData `json:"data,omitempty"` }
SeedConfig represents the configuration for the MongoDB seed component.
Click to show internal directories.
Click to hide internal directories.