mongoprovider

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoProvider

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

MongoProvider is a runtime.ConfigProvider that stores configuration data in a mongodb collection.

func New

func New(cli *mongo.Client, dbName, colName string) *MongoProvider

New returns a new MongoDB backend runtime.ConfigProvider that stores configuration is a collection called colName inside the database dbName. Note that the database indexes should have been setup up already.

func (*MongoProvider) Create

func (pr *MongoProvider) Create(ctx context.Context, sec conf.Section) (string, error)

Create stores a new configuration section in the database collection. It returns the ID of the new record along with any encountered error.

func (*MongoProvider) Delete

func (pr *MongoProvider) Delete(ctx context.Context, id string) error

Delete a configuration object from the database collection.

func (*MongoProvider) Get

func (pr *MongoProvider) Get(ctx context.Context, sectionType string) ([]runtime.Section, error)

Get a list of configuration objects of a given sectionType.

func (*MongoProvider) GetID

func (pr *MongoProvider) GetID(ctx context.Context, id string) (runtime.Section, error)

GetID returns a single configuration object identified by ID.

func (*MongoProvider) Update

func (pr *MongoProvider) Update(ctx context.Context, id, secType string, opts []conf.Option) error

Update an existing configuration object in the database collection. The object is identified by id and secType.

Jump to

Keyboard shortcuts

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