database

package
v0.0.0-...-7b45942 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDBConn

func GetDBConn(
	ctx context.Context,
	uri string,
	dbName string,
) (dbConn *mongo.Database, err error)

Get DB connection instance

func GetDBConnDefault

func GetDBConnDefault(ctx context.Context) (dbConn *mongo.Database, err error)

Get default DB connection instance

func Migrate

func Migrate(ctx context.Context, dbConn *mongo.Database) (err error)

Run the migrations.

func Rollback

func Rollback(ctx context.Context, dbConn *mongo.Database) (err error)

Rollback the migrations.

func Status

func Status(ctx context.Context, dbConn *mongo.Database) (err error)

Check database migration status.

Types

type MigrationInterface

type MigrationInterface interface {
	// Get unique migration name.
	Name() (collectionName string)
	// Do the migration.
	Up(ctx context.Context, dbConn *mongo.Database) (err error)
	// Undo the migration.
	Down(ctx context.Context, dbConn *mongo.Database) (err error)
}

Common migration functionalities.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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