gorm

package
v0.1.34 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GormV1ToV2Adapter

func GormV1ToV2Adapter(v1DB *gormv1.DB) (*gormv2.DB, error)

GormV1ToV2Adapter adapts a GORM v1 connection to a GORM v2 connection

Types

type DBProvider added in v0.1.5

type DBProvider func() (*gorm.DB, error)

DBProvider is a function type that returns the current database connection and an error

type InsertBatcher

type InsertBatcher[T any] struct {
	// contains filtered or unexported fields
}

InsertBatcher is a GORM batcher for batch inserts

func NewInsertBatcher

func NewInsertBatcher[T any](dbProvider DBProvider, maxBatchSize int, maxWaitTime time.Duration, ctx context.Context) *InsertBatcher[T]

NewInsertBatcher creates a new InsertBatcher

func NewInsertBatcherWithOptions added in v0.1.27

func NewInsertBatcherWithOptions[T any](dbProvider DBProvider, ctx context.Context, opts ...batcher.Option) *InsertBatcher[T]

NewInsertBatcherWithOptions creates a new InsertBatcher with custom options

func (*InsertBatcher[T]) Insert

func (b *InsertBatcher[T]) Insert(items ...T) error

Insert submits one or more items for batch insertion

func (*InsertBatcher[T]) InsertAsync added in v0.1.24

func (b *InsertBatcher[T]) InsertAsync(callback func(error), items ...T)

InsertAsync non-blocking version of Insert with a callback

type SelectBatcher added in v0.1.13

type SelectBatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewSelectBatcher added in v0.1.13

func NewSelectBatcher[T any](dbProvider DBProvider, maxBatchSize int, maxWaitTime time.Duration, ctx context.Context, columns []string) (*SelectBatcher[T], error)

NewSelectBatcher creates a new SelectBatcher

func NewSelectBatcherWithOptions added in v0.1.27

func NewSelectBatcherWithOptions[T any](dbProvider DBProvider, ctx context.Context, columns []string, opts ...batcher.Option) (*SelectBatcher[T], error)

NewSelectBatcherWithOptions creates a new SelectBatcher with custom options

func (*SelectBatcher[T]) Select added in v0.1.13

func (b *SelectBatcher[T]) Select(condition string, args ...interface{}) ([]T, error)

func (*SelectBatcher[T]) SelectAsync added in v0.1.24

func (b *SelectBatcher[T]) SelectAsync(callback func([]T, error), condition string, args ...interface{})

SelectAsync non-blocking version of Select with a callback

type SelectItem added in v0.1.13

type SelectItem[T any] struct {
	Condition string
	Args      []interface{}
	Results   *[]T
}

type UpdateBatcher

type UpdateBatcher[T any] struct {
	// contains filtered or unexported fields
}

UpdateBatcher is a GORM batcher for batch updates

func NewUpdateBatcher

func NewUpdateBatcher[T any](dbProvider DBProvider, maxBatchSize int, maxWaitTime time.Duration, ctx context.Context) (*UpdateBatcher[T], error)

Legacy constructor calls the new options-based one

func NewUpdateBatcherWithOptions added in v0.1.27

func NewUpdateBatcherWithOptions[T any](dbProvider DBProvider, ctx context.Context, opts ...batcher.Option) (*UpdateBatcher[T], error)

NewUpdateBatcherWithOptions primary constructor using options

func (*UpdateBatcher[T]) Update

func (b *UpdateBatcher[T]) Update(items []T, updateFields []string) error

Update submits one or more items for batch update

func (*UpdateBatcher[T]) UpdateAsync added in v0.1.24

func (b *UpdateBatcher[T]) UpdateAsync(callback func(error), items []T, updateFields []string)

UpdateAsync non-blocking version of Update with a callback

type UpdateItem added in v0.1.4

type UpdateItem[T any] struct {
	Item         T
	UpdateFields []string
}

Jump to

Keyboard shortcuts

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