dbutil

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: BSD-3-Clause Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFilters

func ApplyFilters(db *gorm.DB, filters map[string]interface{}, defOp ...string) *gorm.DB

func ApplySorts

func ApplySorts(db *gorm.DB, sorts map[string]string, defSort ...string) *gorm.DB

func Exists

func Exists(tx *gorm.DB) (exists bool)

func WithCustomFilter

func WithCustomFilter(op string, opFunc OpFunc)

func WithFilters

func WithFilters(db *gorm.DB, req contracts.RequestContract, key ...string) *gorm.DB

func WithSorts

func WithSorts(db *gorm.DB, req contracts.RequestContract, key ...string) *gorm.DB

Types

type Date added in v0.2.1

type Date struct {
	carbon.Carbon
}

func (Date) MarshalJSON added in v0.2.1

func (d Date) MarshalJSON() ([]byte, error)

func (*Date) ScanInput added in v0.2.2

func (d *Date) ScanInput(data []byte) error

func (*Date) UnmarshalJSON added in v0.2.1

func (d *Date) UnmarshalJSON(row []byte) error

func (Date) Value added in v0.2.1

func (d Date) Value() (driver.Value, error)

type Datetime

type Datetime struct {
	carbon.Carbon
}

func (Datetime) MarshalJSON

func (c Datetime) MarshalJSON() ([]byte, error)

func (Datetime) OfDate added in v0.2.1

func (c Datetime) OfDate() Date

func (*Datetime) ScanInput added in v0.2.2

func (c *Datetime) ScanInput(data []byte) error

func (*Datetime) UnmarshalJSON added in v0.2.1

func (c *Datetime) UnmarshalJSON(row []byte) error

type JsonObjString

type JsonObjString map[string]interface{}

func (*JsonObjString) Scan

func (js *JsonObjString) Scan(src any) error

Scan assigns a value from a database driver. The src value will be of one of the following types:

int64
float64
bool
[]byte
string
time.Time
nil - for NULL values

An error should be returned if the value cannot be stored without loss of information.

Reference types such as []byte are only valid until the next call to Scan and should not be retained. Their underlying memory is owned by the driver. If retention is necessary, copy their values before the next call to Scan.

func (*JsonObjString) ScanInput

func (js *JsonObjString) ScanInput(data []byte) error

func (JsonObjString) Value

func (js JsonObjString) Value() (driver.Value, error)

type OpFunc

type OpFunc func(db *gorm.DB, col string, val interface{}) *gorm.DB

func GetCustomFilter

func GetCustomFilter(op string) (OpFunc, bool)

type Scope

type Scope func(*gorm.DB) *gorm.DB

func WithHas

func WithHas(relation string, fn Scope) Scope

func WithUpsert

func WithUpsert(opts ...UpsertOpt) Scope

type SliceInt

type SliceInt []int64

func (*SliceInt) Scan

func (si *SliceInt) Scan(src any) error

func (SliceInt) Value

func (si SliceInt) Value() (driver.Value, error)

type SliceString

type SliceString []string

func (*SliceString) Scan

func (ss *SliceString) Scan(src any) error

Scan assigns a value from a database driver. The src value will be of one of the following types:

int64
float64
bool
[]byte
string
time.Time
nil - for NULL values

An error should be returned if the value cannot be stored without loss of information.

Reference types such as []byte are only valid until the next call to Scan and should not be retained. Their underlying memory is owned by the driver. If retention is necessary, copy their values before the next call to Scan.

func (SliceString) Value

func (ss SliceString) Value() (driver.Value, error)

type UpsertOpt

type UpsertOpt func(clause.OnConflict) clause.OnConflict

func UpsertOptColumns

func UpsertOptColumns(cols ...string) UpsertOpt

func UpsertOptUpdateAssign

func UpsertOptUpdateAssign(assigns map[string]interface{}) UpsertOpt

func UpsertOptUpdateColumns

func UpsertOptUpdateColumns(cols ...string) UpsertOpt

type WithTimestamps

type WithTimestamps struct {
	CreatedAt Datetime  `gorm:"column:created_at;autoCreateTime;type:timestamp null" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime;type:timestamp null" json:"updated_at"`
}

Jump to

Keyboard shortcuts

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