db

package
v0.0.0-...-98ece37 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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Log    *logrus.Logger
	DBFile string
	DB     *bun.DB
	DBType dialect.Name
	// contains filtered or unexported fields
}

Config configures the database to initialize

func New

func New(options ...Option) *Config

New creates a new instance of Config to create and initialize new database

func (*Config) Init

func (c *Config) Init(ctx context.Context)

Init initializes the database with the given configuration

type Fruit

type Fruit struct {
	bun.BaseModel `bun:"table:fruits,alias:f"`

	ID         int       `bun:",pk,autoincrement,nullzero" json:"id"`
	Name       string    `bun:",notnull" json:"name" `
	Season     string    `bun:",notnull" json:"season"`
	Emoji      string    `bun:"," json:"emoji,omitempty"`
	CreatedAt  time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"-"`
	ModifiedAt time.Time `json:"-"`
}

Fruit model to hold the Fruit data

func (*Fruit) BeforeAppendModel

func (f *Fruit) BeforeAppendModel(ctx context.Context, query schema.Query) error

BeforeAppendModel implements schema.BeforeAppendModelHook

func (*Fruit) String

func (f *Fruit) String() string

type Fruits

type Fruits []*Fruit

Fruits represents a collection of Fruits

func (Fruits) Len

func (f Fruits) Len() int

Len implements sort.Interface

func (Fruits) Less

func (f Fruits) Less(i int, j int) bool

Less implements sort.Interface

func (Fruits) Swap

func (f Fruits) Swap(i int, j int)

Swap implements sort.Interface

type Option

type Option func(*Config)

func WithDBFile

func WithDBFile(dbFile string) Option

func WithDBType

func WithDBType(dbType string) Option

func WithLogger

func WithLogger(log *logrus.Logger) Option

Jump to

Keyboard shortcuts

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