database

package
v1.22.7 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MongoDatabaseName = utils.GetCloudProjectID()

MongoDatabaseName is the name of the database in MongoDB

Functions

func Set

func Set(db *Database)

Set the database object to use

Types

type Database

type Database struct {
	Mdb *mongo.Database

	apis.APIs
}

Database interface abstracts database operations

func Get

func Get() *Database

Get the database object to use

func New

func New() (*Database, error)

New returns a new database object that connects to the real database

func NewWithDb

func NewWithDb(mdb *mongo.Database) *Database

NewWithDb returns a new database object with the given Mongo database

func (*Database) CheckAndFixVisTokenCounts added in v1.20.4

func (db *Database) CheckAndFixVisTokenCounts(ctx context.Context, checkOnly bool) (map[string]map[string]map[string]int, error)

Check vis token counts in all collections. If called in checkOnly mode, only does checks otherwise will also update vis token counts.

If there are any errors, errors are returned in a map with structure: returnedMap[<groupType> + <id>]["visTokenCounts" | "descVisTokenCounts"][<token>] = delta where delta is difference between actual count and expected count.

func (*Database) DbPropsCollection added in v0.11.0

func (db *Database) DbPropsCollection() *mongo.Collection

DbPropsCollection is the collection for database properties

func (*Database) GetSchemaVersion added in v1.0.0

func (db *Database) GetSchemaVersion(ctx context.Context) (int, int, error)

GetSchemaVersion returns (cur, latest) schema version

func (*Database) UpdateIndexes added in v0.11.0

func (db *Database) UpdateIndexes() error

UpdateIndexes if necessary

func (*Database) UpdateIndexesTo added in v0.11.0

func (db *Database) UpdateIndexesTo(version int) error

UpdateIndexesTo to a particular version

func (*Database) UpdateSchemas added in v1.0.0

func (db *Database) UpdateSchemas() error

UpdateSchemas if necessary

func (*Database) UpdateSchemasTo added in v1.0.0

func (db *Database) UpdateSchemasTo(version int) error

UpdateSchemasTo to a particular version

Jump to

Keyboard shortcuts

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