db

package
v0.0.0-...-ede9753 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDatabaseNil         = errors.New("Database is nil")
	ErrInvalidDatabaseType = errors.New("Invalid database type")
	ErrStateNotFound       = errors.New("state not found")
	ErrDuplicateUserMail   = errors.New("User with this email already in database")
)

Default errors

Functions

This section is empty.

Types

type Artifact202303201338

type Artifact202303201338 struct {
	ID        string `gorm:"primaryKey;"`
	ProjectID string `gorm:"primaryKey;column:project_id;not null" sql:"type:uuid;"`
	Size      int    `gorm:"column:size;not null"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func (Artifact202303201338) TableName

func (Artifact202303201338) TableName() string

type Artifact202304131325

type Artifact202304131325 struct {
	ID         string `gorm:"primaryKey"`
	ProjectID  string `gorm:"column:project_id;not null;index" sql:"type:uuid"`
	ArtifactID string `gorm:"column:artifact_id;not null;index"`
	Size       int    `gorm:"column:size;not null"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func (Artifact202304131325) TableName

func (Artifact202304131325) TableName() string

type Config

type Config struct {
	Host string
	Port string

	User     string
	Password string

	Name string

	UseSSL bool
}

func NewConfig

func NewConfig() Config

func (Config) ConnectString

func (c Config) ConnectString() string

func (Config) ForTesting

func (c Config) ForTesting() Config

type Database

type Database interface {
	Gorm() *gorm.DB
	Connect() error
}

func New

func New(opts ...Option) Database

type DatabaseType

type DatabaseType string
const (
	Postgres             DatabaseType = "postgres"
	DigitalOceanPostgres DatabaseType = "digital_ocean_postgres"
)

func (*DatabaseType) String

func (dbt *DatabaseType) String() string

type Option

type Option func(*database)

func WithConfig

func WithConfig(config *Config) Option

func WithDigitalOceanPostgres

func WithDigitalOceanPostgres(token, clusterID string, privateDBConn bool) Option

func WithPostgres

func WithPostgres(host, port, user, password, databaseName string, useSSL bool) Option

type Project202303201338

type Project202303201338 struct {
	ID          string                  `gorm:"primaryKey;" sql:"type:uuid;"`
	Name        string                  `gorm:"column:name;not null"`
	Description string                  `gorm:"column:description;not null"`
	Artifacts   []*Artifact202303201338 `gorm:"foreignKey:ProjectID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

func (Project202303201338) TableName

func (Project202303201338) TableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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