mongo

package
v0.0.0-...-d8d72a7 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollNameSettings = "settings"
	KeyTenantID      = "tenant_id"

	ConnectTimeoutSeconds = 10
)
View Source
const (
	// DbVersion is the current schema version
	DbVersion = "1.0.0"

	// DbName is the database name
	DbName = "azure_iot_manager"
)
View Source
const (
	IndexNameSettingsGet = "settings get"
)

Variables

View Source
var (
	ErrFailedToGetSettings = errors.New("Failed to get settings")
)

Functions

func Migrate

func Migrate(ctx context.Context,
	db string,
	version string,
	client *mongo.Client,
	automigrate bool) error

Migrate applies migrations to the database

func NewClient

func NewClient(ctx context.Context, c config.Reader) (*mongo.Client, error)

NewClient returns a mongo client

func NewDataStoreWithClient

func NewDataStoreWithClient(client *mongo.Client, conf ...*Config) store.DataStore

NewDataStoreWithClient initializes a DataStore object

func SetupDataStore

func SetupDataStore(conf *Config) (store.DataStore, error)

SetupDataStore returns the mongo data store and optionally runs migrations

Types

type Config

type Config struct {
	Automigrate *bool
}

func NewConfig

func NewConfig() *Config

func (*Config) SetAutomigrate

func (c *Config) SetAutomigrate(migrate bool) *Config

type DataStoreMongo

type DataStoreMongo struct {
	*Config
	// contains filtered or unexported fields
}

DataStoreMongo is the data storage service

func (*DataStoreMongo) Close

func (db *DataStoreMongo) Close() error

func (*DataStoreMongo) GetSettings

func (db *DataStoreMongo) GetSettings(ctx context.Context) (model.Settings, error)

func (*DataStoreMongo) Ping

func (db *DataStoreMongo) Ping(ctx context.Context) error

Ping verifies the connection to the database

func (*DataStoreMongo) SetSettings

func (db *DataStoreMongo) SetSettings(ctx context.Context, settings model.Settings) error

Jump to

Keyboard shortcuts

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