mongo

package
v0.0.0-...-1f60312 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

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

	// DbName is the database name
	DbName = "reporting"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoStore

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

MongoStore is the data storage service

func NewMongoStore

func NewMongoStore(ctx context.Context, config MongoStoreConfig) (*MongoStore, error)

SetupDataStore returns the mongo data store and optionally runs migrations

func (*MongoStore) Close

func (db *MongoStore) Close(ctx context.Context) error

Close disconnects the client

func (*MongoStore) Database

func (db *MongoStore) Database(ctx context.Context, opt ...*mopts.DatabaseOptions) *mongo.Database

func (*MongoStore) DropDatabase

func (db *MongoStore) DropDatabase(ctx context.Context) error

func (*MongoStore) GetMapping

func (db *MongoStore) GetMapping(ctx context.Context, tenantID string) (*model.Mapping, error)

GetMapping returns the mapping

func (*MongoStore) Migrate

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

Migrate applies all migrations under the given context. That is, if ctx has an associated identity.Identity set, it will ONLY migrate the single tenant's db. If ctx does not have an identity, all reporting databases will be migrated to the given version.

func (*MongoStore) MigrateLatest

func (db *MongoStore) MigrateLatest(ctx context.Context) error

func (*MongoStore) Ping

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

Ping verifies the connection to the database

func (*MongoStore) UpdateAndGetMapping

func (db *MongoStore) UpdateAndGetMapping(ctx context.Context, tenantID string,
	inventory []string) (*model.Mapping, error)

UpdateAndGetMapping updates the mapping and returns it

type MongoStoreConfig

type MongoStoreConfig struct {
	// MongoURL holds the URL to the MongoDB server.
	MongoURL *url.URL
	// SSL Enables SSL for mongo connections
	SSL bool
	// SkipVerify controls whether a mongo client verifies the server's
	// certificate chain and host name.
	SSLSkipVerify bool
	// Username holds the user id credential for authenticating with the
	// MongoDB server.
	Username string
	// Password holds the password credential for authenticating with the
	// MongoDB server.
	Password string
	// DbName contains the name of the reporting database.
	DbName string
}

Jump to

Keyboard shortcuts

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