Documentation ¶
Index ¶
- Constants
- type MongoStore
- func (db *MongoStore) Close(ctx context.Context) error
- func (db *MongoStore) Database(ctx context.Context, opt ...*mopts.DatabaseOptions) *mongo.Database
- func (db *MongoStore) DropDatabase(ctx context.Context) error
- func (db *MongoStore) GetMapping(ctx context.Context, tenantID string) (*model.Mapping, error)
- func (db *MongoStore) Migrate(ctx context.Context, version string, automigrate bool) error
- func (db *MongoStore) MigrateLatest(ctx context.Context) error
- func (db *MongoStore) Ping(ctx context.Context) error
- func (db *MongoStore) UpdateAndGetMapping(ctx context.Context, tenantID string, inventory []string) (*model.Mapping, error)
- type MongoStoreConfig
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 ¶
GetMapping returns the mapping
func (*MongoStore) Migrate ¶
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 }
Click to show internal directories.
Click to hide internal directories.