mongo

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ComponentType = "mongo seed"

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" yaml:"db,omitempty"`

	// Collection - the name of the target mongo collection
	Collection string `json:"collection,omitempty" yaml:"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" yaml:"documents,omitempty"`
}

type SeedComponent

type SeedComponent struct {
	// contains filtered or unexported fields
}

func NewSeedComponent

func NewSeedComponent(
	clientProvider func() (*mongo.Client, error),
	config SeedConfig,
) *SeedComponent

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

func (m *SeedComponent) EnvVars() map[string]string

func (*SeedComponent) ID

func (m *SeedComponent) ID() string

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 {
	// ID - a unique component name
	ID string `json:"id,omitempty" yaml:"id,omitempty"`

	// Data - a list of objects, each represents a single mongo collection and its data
	Data []*SeedCollectionData `json:"data,omitempty" yaml:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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