database

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Drivers = make(map[string]Driver)

Drivers is a registry of drivers

View Source
var ErrNotFound = errors.New("database: not found")

Functions

func Register

func Register(name string, driver Driver)

Register registers a new driver

Types

type DB

type DB interface {
	Close() error
	Migrate(ctx context.Context) error
	FindMigrationVersion(ctx context.Context) (int, error)

	FindOrganizations(ctx context.Context) ([]*Organization, error)
	FindOrganizationByName(ctx context.Context, name string) (*Organization, error)
	CreateOrganization(ctx context.Context, name string, description string) (*Organization, error)
	UpdateOrganization(ctx context.Context, name string, description string) (*Organization, error)
	DeleteOrganization(ctx context.Context, name string) error

	FindProjects(ctx context.Context, orgName string) ([]*Project, error)
	FindProjectByName(ctx context.Context, orgName string, name string) (*Project, error)
	CreateProject(ctx context.Context, orgID string, name string, description string) (*Project, error)
	UpdateProject(ctx context.Context, id string, description string) (*Project, error)
	DeleteProject(ctx context.Context, id string) error
}

DB is the interface for a database connection

func Open

func Open(driver string, dsn string) (DB, error)

Open opens a new database connection

type Driver

type Driver interface {
	Open(dsn string) (DB, error)
}

Driver is the interface for DB drivers

type Organization

type Organization struct {
	ID          string
	Name        string
	Description string
	CreatedOn   time.Time `db:"created_on"`
	UpdatedOn   time.Time `db:"updated_on"`
}

type Project

type Project struct {
	ID             string
	OrganizationID string `db:"organization_id"`
	Name           string
	Description    string
	CreatedOn      time.Time `db:"created_on"`
	UpdatedOn      time.Time `db:"updated_on"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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