manageddb

package
v0.0.0-...-e510184 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBMigration

type DBMigration struct {
	Up   DBMigrationFunction
	Down DBMigrationFunction
}

DBMigration contains two functions, Up and Down that together perform and undo a set of changes to the database.

type DBMigrationFunction

type DBMigrationFunction func(db *sql.DB) error

DBMigrationFunction gives the signature of functions that can perform database migrations.

type ManagedDB

type ManagedDB struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

ManagedDB has all information pertaining to the database that is being managed. This should probably all be opaque to the user.

func NewManagedDB

func NewManagedDB(dbPath string, driver string, migrations map[int]DBMigration) *ManagedDB

NewManagedDB creates and initializes a new ManagedDB with the given file path, datatbase driver and migrations to apply to the db.

func (ManagedDB) DoWrite

func (mdb ManagedDB) DoWrite(writeFunc ManagedDBWriteFunc) error

DoWrite executes the provided ManagedDBWriteFunc in a safely single-threaded way. All writes to the underlying DB should happen in this way.

type ManagedDBWriteFunc

type ManagedDBWriteFunc func(db *sql.DB) error

Jump to

Keyboard shortcuts

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