bulk_insert

package
v0.0.0-...-eb0ad0d Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: MIT Imports: 7 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BulkInsert

func BulkInsert(db *gorm.DB, objects interface{}, chunkSize int, replace bool, excludeColumns ...string) error

Insert multiple records at once [objects] Must be a slice of struct [chunkSize] Number of records to insert at once.

Embedding a large number of variables at once will raise an error beyond the limit of prepared statement.
Larger size will normally lead the better performance, but 2000 to 3000 is reasonable.

[excludeColumns] Columns you want to exclude from insert. You can omit if there is no column you want to exclude.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(opts ...BuilderOpt) *Builder

func (*Builder) Exec

func (b *Builder) Exec(db *gorm.DB, objects interface{}) error

type BuilderOpt

type BuilderOpt func(*Builder)

func ChunkSizeOpt

func ChunkSizeOpt(chunkSize int) BuilderOpt

func ExcludeColumnsOpt

func ExcludeColumnsOpt(excludeColumns []string) BuilderOpt

func ReplaceOpt

func ReplaceOpt(replace bool) BuilderOpt

Jump to

Keyboard shortcuts

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