gormf

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package gormf contains utilities & extensions for gorm.io/gorm package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectTaggedColumns

func CollectTaggedColumns(entity interface{}, setting string) map[string]string

CollectTaggedColumns collects all columns from this entity tagged with a setting from this entity and all its embedded structs.

func Filter added in v0.10.5

func Filter(tx *gorm.DB, entity any, setting string, operator string, value any) (*gorm.DB, error)

Filter applies filter based on tagged field struct. setting is used to specify gorm setting in struct field tag which is used to resolve the column for filtering.

func LogfLogger added in v0.10.5

func LogfLogger(clock syncf.Clock, name ...any) logger.Interface

LogfLogger returns a logger.Interface adapter for logf.

func OnConflictClause

func OnConflictClause(entity interface{}, setting string, updateAll bool, doUpdates clause.Set) *clause.OnConflict

OnConflictClause generates ON CONFLICT clause containing columns tagged with "setting" in the struct of "entity".

Types

type Batch added in v0.10.5

type Batch[T any] []T

Batch is a slice of values.

func (Batch[T]) Ensure added in v0.10.5

func (b Batch[T]) Ensure(db *gorm.DB, keySetting string) error

Ensure inserts values from this batch into db, updating existing rows. keySetting is used to specify struct field tag for collecting fields for ON CONFLICT clause.

func (Batch[T]) EnsureSince added in v0.10.5

func (b Batch[T]) EnsureSince(db *gorm.DB, since time.Time, keySetting string) error

EnsureSince detects time column (which must be tagged with `gorm:"time"`), removes all existing rows with time >= since and inserts the batch with Ensure.

type JSONB

type JSONB json.RawMessage

JSONB provides PostgreSQL jsonb type support for gorm.

func ToJSONB

func ToJSONB(value any) (JSONB, error)

ToJSONB converts the specified value to jsonb.

func (JSONB) As added in v0.11.0

func (j JSONB) As(value any) error

func (JSONB) GormDataType

func (j JSONB) GormDataType() string

func (*JSONB) Scan

func (j *JSONB) Scan(value any) error

func (JSONB) String

func (j JSONB) String() string

func (JSONB) Value

func (j JSONB) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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