db

package module
v0.0.0-...-a18d784 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicEntity

type BasicEntity interface {
	GetId() uuid.UUID
}

type BasicFields

type BasicFields struct {
	ID        uuid.UUID `gorm:"type:uuid;primarykey"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*BasicFields) BeforeCreate

func (basic *BasicFields) BeforeCreate(tx *gorm.DB) (err error)

func (*BasicFields) BeforeUpdate

func (basic *BasicFields) BeforeUpdate(tx *gorm.DB) (err error)

type BasicRepository

type BasicRepository[T BasicEntity] interface {
	FindByID(id uuid.UUID) (*T, error)
	FindAll() ([]T, error)
	Save(t *T) (*T, error)
	Delete(id uuid.UUID) error
	Exists(id uuid.UUID) (bool, error)
	Count() (int64, error)
}

func NewBasicRepository

func NewBasicRepository[T BasicEntity](serverContext *DBContext) BasicRepository[T]

type DBContext

type DBContext struct {
	DB *gorm.DB
}

Jump to

Keyboard shortcuts

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