mongo

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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) Cleanup

func (m *SeedComponent) Cleanup(context.Context) error

func (*SeedComponent) Config

func (m *SeedComponent) Config() any

func (*SeedComponent) Prepare

func (m *SeedComponent) Prepare(context.Context) error

func (*SeedComponent) Start

func (m *SeedComponent) Start(ctx context.Context) error

func (*SeedComponent) Status

func (*SeedComponent) Stop

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.

Jump to

Keyboard shortcuts

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